Use of Persistence API

Hi,
          I want to know any business scenario, or any case where the Persistence API are explicitly needed.Whenever we use a smart sync application based on the metaRep.xml file the persistence to the DB2E or filesystem is taken care of by the Framework itself . So where do we need to implement it?
Thanks in Advance
Veerabhadram

Hi Veerabhadram,
Mobile Asset Management application is using both Framework persistence to download/upload data (with SmartSync, via SyncBo) and local persistence.
When data is local and only serves to run application we persist it locally.
One example - all lists in application are defined in xml file, which is rendered either when application run first or xml file is changed. We persist rendering results for performance purposes.
Cheers,
Larissa Limarova

Similar Messages

  • Newbie, Help using the persistence API

    Hi all,
    I am trying to implement 1 : n relations between objects.
    In the  SAP example (Persistence example) you can see this:
    P_CLASS_CAR = PDR.createClassDescriptor(Car.CLASSTYPE, CAR_ATTRIBS, new LinkDescriptor[] { PDR.createLinkDescriptor("license", License.CLASSTYPE, MultiplicityType.SINGLE, true)});
    P_CLASS_LICENSE = PDR.createClassDescriptor(License.CLASSTYPE, NO_ATTRIBS, new LinkDescriptor[] { PDR.createLinkDescriptor("car", Car.CLASSTYPE, MultiplicityType.SINGLE, true)});
    In this case we had a that one (1) car has one (1) License or 1:1 relation
    But what about if the relations are 1:n for example one car with many license? Should i use this...
    P_CLASS_CAR = PDR.createClassDescriptor(Car.CLASSTYPE, CAR_ATTRIBS, new LinkDescriptor[] { PDR.createLinkDescriptor("license", License.CLASSTYPE, MultiplicityType.<b>MULTIPLE_VECTOR</b>, true)});
    P_CLASS_LICENSE_<b>1</b> = PDR.createClassDescriptor(License.CLASSTYPE, NO_ATTRIBS, new LinkDescriptor[] { PDR.createLinkDescriptor("car", Car.CLASSTYPE, MultiplicityType<b>.SINGLE</b>, true)});
    P_CLASS_LICENSE_<b>2</b> = PDR.createClassDescriptor(License.CLASSTYPE, NO_ATTRIBS, new LinkDescriptor[] { PDR.createLinkDescriptor("car", Car.CLASSTYPE, MultiplicityType<b>.SINGLE</b>, true)});
    P_CLASS_LICENSE_<b>n</b> = PDR.createClassDescriptor(License.CLASSTYPE, NO_ATTRIBS, new LinkDescriptor[] { PDR.createLinkDescriptor("car", Car.CLASSTYPE, MultiplicityType.<b>SINGLE</b>, true)});
    So i have to put the MULTIPLE_VECTOR instead of SINGLE  to say that there is a 1:n relation for example one (1) car have n licenses but  one (1) license   belongs to only one car. Is this correct?
    Best Regards,
    Erick Ilarraza

    Hi Philipp,
    Yes, I can work with persistence objects, did you need help? I can send you some code with a little of information.
    In this moment I am trying to work with the Synchronization, but It didn't work!!
    Best Regards,
    Erick Ilarraza

  • Persistence API & dynamic database names

    Hi I want to use the persistence API but change the database at run time.
    So as an exampleI have a Users table with exactly the same structure in different databases. At run time I want to make the decision as to which database to query. With JDBC I have somthing like:
    String sql = "Select UserName From "+dbName+".Users";
    I would like to do the same sort of thing. I know that the @Table tag has a schema="" modifier but this is complile time.
    Thanks in advance.

    As you have a specifc number of blocks (with tables), i would you with an IF-statement, and check directly agaisnt each of the tables without doing anything dynamic.

  • Java persistence api : ejb ql

    Hi,
    I am using java persistence api(over oracle toplinks)
    I have an entity customer and another entity contacts.
    customer is mapped with contact as one to many.
    the contact have a field primarycontact.
    I want to get the contact name from contacts for a customer where primarycontact field is true. and set this contact name as a field customercontact which is a string in customer..
    I got a way by executing multiple queries.
    but is it possible to do this in single query using ejb ql?
    Any help will be greatly appreciated..
    Thanks in advance....

    @Id
    @GeneratedValue( @GeneratedValue(strategy= GenerationType.TABLE, generator="SOMENAME")
    public int setId() {
    returrn this.id;
    in the database you need to create table using following commands
    CREATE TABLE SEQUENCE
    SEQ_NAME VARCHAR(50),
    SEQ_COUNT DECIMAL(15)
    and insert a row initally with the same "SOMENAME" like
    insert into sequence values ( "SOMENAME", 1);
    you can get the next id by adding 50(default) to "SELECT SEQ_COUNT FROM SEQUENCE WHERE SEQ_NAME = "SOMENAME"
    hope this provides a solution.

  • EJB 3.0 Persistence API and Stored Procedures

    Does the EJB 3.0 Persistence API in any way prescribe or facilitate the use of Stored Procedure calls? Given the recent popularity of using (database) server APIs consisting of Stored Procedures that are addressed by ORM frameworks for performing the DML operations and of course the general usefulness of stored procedures for specific data related operations, there definitely is a need for clarity on using the straightforward Persistence operations in combination with calls to Stored Procedures. Can we use the Native Query for executing CallableStatements? Can we get to a Connection instance from the EntityManager? Can we easily use the results from a Stored Procedure invocation to refresh our Domain Objects - or is that all application logic in which the EntityManager cannot help us?
    If the spec does not help us at this point, do you know how TopLink will deal with this topic?
    Thanks for any help you can give me!
    Best regards,
    Lucas Jellema

    I'm am also interested in a response to this post. I've just upgraded to JDeveloper 10.1.3.1 and am interested in making calls to stored procedures.
    I've found examples of just creating my own session beans but it seems I would have to hard code the datasource name. Does anyone know if I can get around this using the entity manager supplied by the tool?
    thanks,
    Dan

  • Java Persistence API and creation of databases

    Hi All
    I have designed a small address book application which uses a database to store the information. I have used the new Java Persistence API to take care of my transactions and querrys with the database. This works great for one set database which is generated the first time the application runs and is used all the time.
    However I would like to make it so that the user can create a new address book (database) with a different name, I am not sure how I would do this using the Java Persistence API. I know the persistence.xml file must be placed in the META-INF directory of the source, so how would I be able manipulate the file or could I place the file somewhere else.
    David

    I am using the Derby database. I can create a database by passing the create command when I create the entity Manager like so:
    Connection c = DriverManager.getConnection("jdbc:derby:AddressBook;create=true", "app", "app");My problem is that as I understand it the persistence.xml file must know the name of the database. Unless there is another way of setting this. The line in the persistence file I am referring to is:
    <property name="toplink.jdbc.url" value="jdbc:derby:AddressBook"/>I wonder if I can progamatically set this value so that I have a default database in the persistence.xml and others can then create there own.
    David

  • How to use the UME api in order to search the LDAP?

    Hello,
    I have an application which connects to the LDAP the portal is connecting to and search users according to a certain search criteria.
    Here is the relevant piece of code:
    Hashtable env = new Hashtable();
    DirContext ctx = new InitialDirContext(env);
    SearchControls controls = new SearchControls();
    String filter = "firstName=..."
    NamingEnumeration results = ctx.search("OU=OUs", filter, controls);
    I would like to do this same search using the UME API.
    Can someone please show me the equivalent code to it using the UME API?

    Hi Roy,
    you find the Configuration File you are using in your portal via System Administration -> System Configuration -> UM Configuration -> Data Sources
    or in sapume.properties where you can find
    ##xml file that configures the persistence except roles
    ume.persistence.data_source_configuration=YOUR_DATASOURCE_CONFIG_FILE.xml
    In this xml file, there is the entry
    <principal type="user">:
    <principal type="user">
         <nameSpaces>
         <nameSpace name="com.sap.security.core.usermanagement">     
    <attributes>                               
    <attribute name="firstname" populateInitially="true"/><attribute name="displayname" populateInitially="true"/>               <attribute name="lastname" populateInitially="true"/>                    <attribute name="fax"/>                         <attribute name="email"/>                    <attribute name="title"/>               <attribute name="department"/>                    <attribute name="extensionAttribute2"/>               <attribute name="mobile"/>          <attribute name="telephone"/>                    <attribute name="streetaddress"/>               <attribute name="pobox"/>                    <attribute name="location"/>               <attribute name="telephoneShort"/>               </attributes>
         </nameSpace>
         <nameSpace name="com.sap.security.core.usermanagement.relation">
         <attributes>
         <attribute name="PRINCIPAL_RELATION_PARENT_ATTRIBUTE"/>
         </attributes>
         </nameSpace>
        </nameSpaces>
    </principal>
    According to your company LDAP attributes, you will have to extend the above attributes, telephoneShort for example is an attribute within our company.
    The UME API does the rest.
    All you have to do, is request the right attribute (in my above example it was the last name).
    (Sorry for the format, but it is quite cumbersome to format it properly with the available editor   )
    Kind regards,
    Rebecca

  • Applet Persistence API - without loosing data??

    I'm using the Applet Persistence API (AppletContext.setStream / getStream) so store private data in the jvm - like session-cookies in the browser.
    Since the next-generation java-plugin this method stopped working because the java-plugin might terminate and restart the jvm during a browser session and all data is lost.
    Is it possible to prevent the java-plugin from stopping a jvm during a browsers session - for example via parameters in the applet tag?

    tronix wrote:
    ..Since the next-generation java-plugin this method stopped working ..The next-gen. plug-in allows applets to hook into the PersistenceService of the JNLP API - when they are deployed using JNLP. I have a demo. of the PersistenceService (http://pscode.org/jws/api.html#ps).
    It would be possible to create two versions of the applet. Version one is your current applet that uses the older methods for persistence. Version 2 uses the new methods.
    To decide between them on the client side, present the plug-in 2 applet in an applet element that loads the version 1 applet as the standard applet alternative to the version 2 applet.

  • Newbie question on Java Persistence API - Entity Beans

    Hi All,
    I am basically new to Entities and the Java Persistence API. My question is, when using a container managed EntityManager, do I have to manually tidy-up any resources? Say for example, do I have to explicitly close the database connection (if ever I have that ability)? Invoke close() on EntityManager?
    - Pat

    You don't have to. That's what they mean by container managed. The container does it for you.
    In fact you will get an IllegalStateException if you call close on a container-managed EntityManager.

  • Can anuone help me on persistence API problem please?

    I would like someone to explain me why when using persistence API
    sometime i can insert data in database normally but later when i
    have added more functionalities like ajax, and file upload i can
    insert data in database using persistence API.
    for instance, using this i was able in the begin of my development
    but now i am not:
    utx.begin();
    inst.insert(name, email); 
    utx.commit();replace the code above by this below i can insert the data
    at the same step of my project:
    Class.forName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource").newInstance();
                con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/loja?user=marcos&password=131283");     
                String selectStatement = "insert into cadastroswebradio values(?, ?)";
                PreparedStatement prepStmt = con.prepareStatement(selectStatement);
                prepStmt.setString(1, name);
                prepStmt.setString(2, email);So what's the problem? could anyone help me?Thanks!!
    this explain either:http://forum.java.sun.com/thread.jspa?threadID=764824

    Basically i totally not understand your question and i believe also nobody would understand what is your question. You mean your persistence APIs, but you didnt show how the APIs and just use it, i can say that, the only different of that JDBC and your 'persistence', is your JDBC isnt commit function(not include auto-commit). What i can see is that's all.
    But the idea of usage DB conn API should be correct with the 3 steps,
    Begin - Open connection
    Query - insert/update/delete
    Close - commit
    catch - Rollback
    Hopefully it helps.

  • Can anyone help me on persistence API problem?

    I would like someone to explain me why when using persistence API
    sometime i can insert data in database normally but later when i
    have added more functionalities like ajax, and file upload i can
    insert data in database using persistence API.
    for instance, using this i was able in the begin of my development
    but now i am not:
    utx.begin();
    inst.insert(name, email); 
    utx.commit();replace the code above by this below i can insert the data
    at the same step of my project:
    Class.forName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource").newInstance();
                con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/loja?user=marcos&password=131283");     
                String selectStatement = "insert into cadastroswebradio values(?, ?)";
                PreparedStatement prepStmt = con.prepareStatement(selectStatement);
                prepStmt.setString(1, name);
                prepStmt.setString(2, email);So what's the problem? could anyone help me?Thanks!!
    this explain either:http://forum.java.sun.com/thread.jspa?threadID=764824

    Basically i totally not understand your question and i believe also nobody would understand what is your question. You mean your persistence APIs, but you didnt show how the APIs and just use it, i can say that, the only different of that JDBC and your 'persistence', is your JDBC isnt commit function(not include auto-commit). What i can see is that's all.
    But the idea of usage DB conn API should be correct with the 3 steps,
    Begin - Open connection
    Query - insert/update/delete
    Close - commit
    catch - Rollback
    Hopefully it helps.

  • Question about Java Persistence API.

    is Java Persistence API a Object-Relational Mapping Framework, or the java Programmer can use this API to do mapping between Java Applicatiion and Relational Database ??

    http://java.sun.com/javaee/overview/faq/persistence.jsp

  • DAO pattern and Java Persistence API

    Hi
    This is a question for anyone who might be familiar with the standard DAO design pattern and the Java Persistence API (JPA - part of EJB3). I'm new to this technology, so apologies for any terminology aberrations.
    I am developing the overall architecture for an enterprise system. I intend to use the DAO pattern as the conceptual basis for all data access - this data will reside in a number of forms (e.g. RDBMS, flat file). In the specific case of the RDBMS, I intend to use JPA. My understanding of JPA is that it does/can support the DAO concept, but I'm struggling to get my head around how the two ideas (can be made to) relate to each other.
    For example, the DAO pattern is all about how business objects, data access objects, data transfer objects, data sources, etc relate to each other; JPA is all about entities and persistence units/contexts relate to each other. Further, JPA uses ORM, which is not a DAO concept.
    So, to summarise - can DAO and JPA work together and if so how?
    Thanks
    P.S. Please let me know if you think this topic would be more visible in another forum (e.g. EJB).

    Thanks, duffymo, that makes sense. However ... having read through numerous threads in which you voice your opinion of the DAO World According to Sun, I'd be interested to know your thoughts on the following ...
    Basically, I'm in the process of proposing an enterprise system architecture, which will use DAO as the primary persistence abstraction, and DAO + JPA in the particular case of persistence to a RDBMS. In doing so, I'd like to illustrate the various elements of the DAO pattern, a la the standard class diagram that relates BusinessObject / DataAccessObject / DataSource / TransferObject (http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html). With reference to this model, I know that you have a view on the concept of TransferObject (aka ValueObject?) - how would you depict the DAO pattern in its most generic form? Or is the concept of a generic DAO pattern compromised by the specific implementation that is used (in this case JPA)?

  • Persistence API newbie question

    Hello everybody!
    I am new at J2EE development, so can you explain me some details. We're curently do J2EE application at work and using J2EE 1.5 features(EJB 3.0, Persistence etc..). I don't understand exactly what lies under annotations. Let's take Persistence API. All anotations and classes is in javax.persistence package. What is that package, where it come from? Is it located in container or where? In fact I would like to use Persistence API on sites managed by Apache Tomcat Server. Is it possible, what classes do I need? Another question is it is possible to use that API at Swing Applications, and what do I need to do this.
    Please, explain me little of where all that stuff come from.
    Thank you!

    anotations and classes is in javax.persistence
    package. What is that package, where it come from? Is
    it located in container or where? Java Persistence API (JPA) is part of JavaEE 5 platform, and so is available in all JavaEE 5 compliant application servers. In JavaEE SDK 5, these classes are in lib/javaee.jar. JPA is also available as a standalone technology. There are several products that are implementing this technology, like Hibernate, TopLink, or OpenJPA.
    The specification:
    http://jcp.org/en/jsr/detail?id=220
    Persistence Part in JavaEE 5 Tutorial (Part Four: Persistence )
    http://java.sun.com/javaee/5/docs/tutorial/doc/
    In fact I would
    like to use Persistence API on sites managed by
    Apache Tomcat Server. Is it possible, what classes do
    I need? Another question is it is possible to use
    that API at Swing Applications, and what do I need to
    do this. They are all possible ways of using JPA. See JavaEE 5 Tutorial for more details. The newly released NetBeans 5.5 has nice support for developing and deploying JPA applications. NetBeans site has a lot of resources on this topic. For example:
    http://www.netbeans.org/kb/55/persistence_ontomcat.html
    http://www.netbeans.org/kb/articles/hibernate-javaee.html
    -cheng

  • Any good documentation of the Applet Persistence API ?

    Does anybody have links to good documentation for the Applet Persistence API? I am talking about the new getStream and setStream methods on the AppletContext class. The official documentation I have been able to find simply sucks:
    http://java.sun.com/j2se/1.4/docs/guide/plugin/developer_guide/persistence.html
    A search on this forum and on Google didn't reveal much either. It seems like an almost undocumented feature.
    If you have any links or if you have some hands-on experience with the Applet Persistence API, then please share it. :)

    I'm resurrecting this old thread because I think its pretty funny that in five years this seems to have only gotten more confusing. I don't think anyone is using it (ie. google was still no help) but I'm hoping someone can shed some light.
    I got the distinct impression from... something I thought I read but must have hallucinated... that this API is supposed to persist information across browser runs. Even if that's not the case, I'm curious why I can't get the stated functionality to work. I tried the only sample I could find from this page:
    http://www.java-tips.org/java-se-tips/java.applet/working-with-applet-context-streams.html
    The sample is quite good even if it leaves out the most important information about the API, which the previous poster provided (that its not 'real' persistence). Unfortunately, it doesn't seem to work with the latest release JRE. Through the debugger I'm seeing that the setStream call is happening as expected but the getStreamKeys routine always returns null. Can someone who has successfully used this enlighten me?
    Thanks,
    - David

Maybe you are looking for