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

Similar Messages

  • 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.

  • 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

  • EE 5 newb question

    My question revolves around remote interfaces and using the persistence API. An example might give more insight into my question�
    I have 3 tables Customer, Order, LineItem with the corresponding object associations:
    class Customer {
    long id;
    List<Order> orders;
    public long getId() {};
    public List<Order> getOrders(){};
    class Order {
    long id;
    List<LineItem> lineItems;
    public long getId() {};
    public List<LineItem> getLineItems() {};
    public Customer getCustomer() {};
    Class LineItem {
    long id;
    public long getId() {};
    public Order getOrder() {};
    When using a session bean that implements a remote interface I make a call similar to the following�
    @Stateless
    class OrderBean implements RemoteOrder {
    public List<Order> getOrders(long custId) {
    return em.createNamedQuery(�order.findByCustomerId�).setParmater(�custId�, custId);
    Now this would work great in a Servlet/JSP that was running in the same JVM, but I am accessing this from a web service. I am wondering what is the �standard� way to return the persistent data to the web service client?
    Is it off load every thing into a value object? Something has to be done otherwise I will always get exceptions when trying to access the lazy children of Customer. Even if I do a FETCH JOIN for Customer.lineItems then the problem nest down
    to Order.lineItems, should I FETCH JOIN this to? What about the cyclic call during marhsalling from Customer.getOrders() -> Orders.getCustomers()? I have yet to find documentation �anywhere� ;) that defines a standard way
    to handle this or should we still develop the J2EE way and use Transfer Objects, but I thought the persistence layer and POJOs was supposed to remove this extra layer from the enterprise application.
    Thanks for any help
    J

    The tape device /dev/rmt/0 can be accessed through a number of "names". The exact name used indicates a exactly how the hardware should access the device.
    /dev/rmt/0n is the no rewind version. If you don't add the n then the tape will be automatically rewound on close.
    You have to use that version if you want to dump multiple things onto the tape one after the other.

  • Newbie question abount managing java libraries

    Hello all,
    I'm rahter new to Java and have a question about how to manage java libraries in a central location. I've been told to use Maven, but I don't need/want to use it.
    I'm only asking a way to have centralized the different Java libraries that a Developer Team may use in a form that they could download to their PCs and use in their projects, thinking in a free IDE environment where could be JDeveloper, NetBeans and Eclipse in use.
    I'm thinking in use Subversion to upload the different Java libraries files to a Subversion Repository and then each Developer Team doing a checkout of what they need, but I think it's not the primary use to do with the versioning system.
    Please, could somebody point me out if there is any product that could fit my needs about managing Java libraries ?
    Thanks in advance.
    Angel.

    - limit the set of packages to those which have been approved by the processYou can constrain Maven to only use an internal repository from which to pull libraries. If you don't put the libraries in the repository you can't use them in your project.
    - limit the packages by licenseI don't think there's anything built in to do this. There's a space for that information in the pom (metadata) file though, so it would be possible to do so. You'd probably have to do some work on the repository to bring ensure the fields was populated though - I get the impression that it tends not to be by default.
    - produce audit logs of what the dependencies and licenses used by each project isDependencies yes, certainly. Licenses again I don't think there's anything existing but you could probably adapt the dependency plugin to report this.
    Example dependency tree generated by Maven for JA-SIG CAS:
    [INFO] [dependency:tree]
    [INFO] org.jasig.cas:cas-server-webapp:war:3.2.1
    [INFO] +- log4j:log4j:jar:1.2.15:runtime
    [INFO] +- net.sf.ehcache:ehcache:jar:1.4.0-beta2:runtime
    [INFO] |  +- net.sf.jsr107cache:jsr107cache:jar:1.0:runtime
    [INFO] |  \- backport-util-concurrent:backport-util-concurrent:jar:3.0:runtime
    [INFO] +- commons-lang:commons-lang:jar:2.2:runtime (scope not updated to compile)
    [INFO] +- quartz:quartz:jar:1.5.2:compile
    [INFO] +- org.springframework.ldap:spring-ldap:jar:1.2.1:compile
    [INFO] +- org.springframework.ldap:spring-ldap-tiger:jar:1.2.1:compile
    [INFO] +- org.springframework:spring-webmvc:jar:2.5.1:compile
    [INFO] |  +- org.springframework:spring-beans:jar:2.5.1:compile
    [INFO] |  +- org.springframework:spring-context:jar:2.5.1:compile
    [INFO] |  +- org.springframework:spring-context-support:jar:2.5.1:compile
    [INFO] |  +- org.springframework:spring-core:jar:2.5.1:compile
    [INFO] |  \- org.springframework:spring-web:jar:2.5.1:compile
    [INFO] +- javax.servlet:jstl:jar:1.1.2:compile
    [INFO] +- javax.servlet:servlet-api:jar:2.4:provided (scope not updated to compile)
    [INFO] +- ognl:ognl:jar:2.6.9:runtime (scope not updated to compile)
    [INFO] +- junit:junit:jar:3.8.1:test
    [INFO] +- org.acegisecurity:acegi-security:jar:1.0.6:runtime
    [INFO] |  +- commons-codec:commons-codec:jar:1.3:runtime
    [INFO] |  \- oro:oro:jar:2.0.8:runtime
    [INFO] +- cas:casclient:jar:2.1.1:runtime
    [INFO] +- org.springframework:spring-aop:jar:2.5.1:compile
    [INFO] |  \- aopalliance:aopalliance:jar:1.0:compile
    [INFO] +- org.springframework:spring-test:jar:2.5.1:test
    [INFO] +- commons-logging:commons-logging:jar:1.1:compile
    [INFO] +- org.springframework:spring-webflow:jar:1.0.5:compile
    [INFO] |  \- org.springframework:spring-binding:jar:1.0.5:compile
    [INFO] +- org.inspektr:inspektr-core:jar:0.6.1:compile
    [INFO] |  +- aspectj:aspectjweaver:jar:1.5.3:runtime
    [INFO] |  +- aspectj:aspectjrt:jar:1.5.3:compile
    [INFO] |  \- org.springframework:spring-jdbc:jar:1.2.9:compile
    [INFO] |     \- org.springframework:spring-tx:jar:2.5.1:compile
    [INFO] +- org.jasig.cas:cas-server-core:jar:3.2.1:compile
    [INFO] |  +- org.jasig.service:person-directory-impl:jar:1.1.1:compile
    [INFO] |  |  +- org.jasig.service:person-directory-api:jar:1.1.1:compile
    [INFO] |  |  \- commons-collections:commons-collections:jar:3.2:compile
    [INFO] |  +- jdom:jdom:jar:1.0:compile
    [INFO] |  +- org.springframework:spring-orm:jar:2.5.1:compile
    [INFO] |  +- org.apache.santuario:xmlsec:jar:1.4.0:runtime
    [INFO] |  +- org.opensaml:opensaml:jar:1.1b:compile
    [INFO] |  +- javax.persistence:persistence-api:jar:1.0:compile
    [INFO] |  \- javax.xml:xmldsig:jar:1.0:compile
    [INFO] \- taglibs:standard:jar:1.1.2:compile

  • 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.

  • 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)?

  • Web services + persistence API

    Hello everyone, I'm new here and have a silly question to ask.
    Is it possible to generate entity classes from database by using persistence API then wrap them in web services with jaxws? Thanks!

    Thanks... Any tips on how to do it? preferably without much coding.

  • 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

  • Total Newbie Question ... Sorry :-(

    I know it's a windows thing, and I am now converted to Mac but I gotta know this because it's doing my head in. It's a complete stupid green gilled newbie question.
    When installing new programs on a Mac can you create shortcuts to the programs on the Dock? I did what I THOUGHT it would be, i.e I made an Alias and stuck it in the dock, but on rebooting my Mac later on, in place of the shortcuts where 3 question marks which when clicked on did absolutely nothing???
    Help?
    A.L.I
    Windows XP Pro Desktop, Macbook Pro, 60GB iPod Video   Mac OS X (10.4.5)   OS X

    You aren't installing something from a dmg file are you? The dmg is a disk image – kind of a virtual CD. So when you double click the dmg and then get the little disk/hardrive/custom icon on your desktop that is the same as if you had mounted a CD. You then need to drag the application off of that "CD" into your application folder. Then it is truly installed.
    You can then "eject" the icon your your desktop. This is what happens when you shutdown and without remounting the image your dock shortcut can't find the original.
    Just a thought.

  • Newbie Question. just installed IE7.. how do I set up a local host to preview sites?

    Sorry for the newbie question... but it's been a long time since I have done this
    Thanks!

    Just define your site in DW as always.  For a static site, that's all you need to do.

  • Newbie Question about FM 8 and Acrobat Pro 9

    Hello:
    I have some dcouments that I've written in FM v8.0p277. I print them to PDF so that I can have a copy to include on a CD and I also print some hard copies.
    My newbie question is whether there is a way to create a  PDF for hard copy where I mainitain the colors in photos and figures but that the text that is hyperlinked doesn't appear as blue. I want to keep the links live within the soft copy. Is there something I can change within Frame or with Acrobat?
    TIA,
    Kimberly

    Kimberly,
    How comes the text is blue in the first place? I guess the cross-reference formats use some character format which makes them blue? There are many options:
    Temporarily change the color definition for the color used in the cross-reference format to black.
    Temporarily change the character format to not use that color.
    Temporarily change the cross-reference definition to not used that character format.
    Whichever method you choose, I would create a separate document with the changed format setting and import those format into your book, create the PDF and then import the same format from the official template.
    - Michael

  • 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.

Maybe you are looking for

  • Alarm mac app the works with screensaver password enabled?

    I am looking for an alarm clock app on my Macbook (running Mavericks) that would work even if I have the screensaver/sleep password enabled. Of course, I want the Macbook go to sleep during the night. Does anyone know of such an application? I have l

  • Settings for USER MASTER in PRINTING?

    In The tcode : CO02 for Prod Order , I specify under menu path : Order-settings-listcontrol-for Lp01 printer : 0909 . In the user master record the printer SPLD is 7205. I want that the printer setting on the screen ( 0909 ) should override the setti

  • Opening links to pdf files using safari

    While using safari and clicking on a link to a pdf file, a new page loads that is just totally black. If I use the firefox browser and click on the same link, a new page opens and displays the pdf perfectly. While using safari, if I choose to downloa

  • Clarify these

    Hi bw gurus, can u plz explain me these. 1. how do you convert tech spec to functional spec? 2. any toughest scenario in implementation proj?( plz for interview purpose} points fully assured*** Thanq, Madhavi

  • OIM 9102 BP12 Migration from WebSphere 6.1 to Weblogic 10.3

    Hello, We're planning to move(9102BP12) from WebSphere6.1 to Weblogic10.3. I found Oracle metalink which says - ================================================ JDK Migration restriction: You can only migrate to JDKs that falls with in the same group