|
Sponsored Links
Resources
Enterprise Java Research Library
Get Java white papers, product information, case studies and webcasts
|
News
News
News
|
Messages: 24
Messages: 24
Messages: 24
Printer friendly
Printer friendly
Printer friendly
Post reply
Post reply
Post reply
XML
XML
XML
|
 |
Introduction to using Java Persistence API in a web application
Sanjeeb Kumar has written up a walkthrough for using EJB3 persistence in a simple web application. While this has been done elsewhere (and referenced on TSS and other sites), this entry is interesting because of its simple and clear nature and references, which make it easy to follow.
Other interesting facets: it uses the Glassfish EJB3 reference implementation (as opposed to Hibernate 3, although it'd be interesting to see if the use of Hibernate changed anything in the walkthrough), and also references Java2DB, a tool provided in Glassfish that can create a database schema from a set of entity beans.
|
|
Message #192847
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Generating tables from Beans
First let me say that I have read the spec and built a couple very small sample applications myself. Based on my expirence so far I really like EJB and think that the people involved did a great job bringing it together.
I'm also sure that once Rod and co. build a wrapper for EJB3 that the spring people will be fine with it too ;)
My question is weather there are plans for javax.persistence to become part of Java SE? It seems to me that all of Java could benefit from this API not just application server based applications.
|
|
Message #192848
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Generating tables from Beans
Sorry for the title I was orig going to ask a different question but changed my mind.
|
|
Message #192858
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Matt, did you like the 'simple and clear nature' of this entry?
First let me say that Stop - You have to. First, I will let you say whether you liked the 'simple and clear nature' and 'easy to follow feature' of this article. Then, you may proceed with your usual question(s).
TSS has done and is doing a superb job of highlighting the very good work of 'Sanjeeb Kumar' (here) and of 'Binod P.G' (http://www.theserverside.com/news/thread.tss?thread_id=37863#192695).
Nice!!! <= this is admiration for TSS for its job of coverage. Ok. And Thank you.
|
|
Message #192860
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Matt, did you like the 'simple and clear nature' of this entry?
First, I will let you say whether you liked the 'simple and clear nature' and 'easy to follow feature' of this article. ha ha ha Sorry but I can't say, I didn't bother reading it. I'm just taking advantage of the fact that this post relates to EJB3 ;)
|
|
Message #192869
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Generating tables from Beans
Yes. If I recollect it right, Linda (JSR 220 EJB3 Spec Lead) mentioned in JavaPolis 2004 that this API is going to be part of JSE as well.
So, you are right (and community believes) that all of Java could benifit from this API.
--Anshuman
|
|
Message #192875
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
JPA 1.0 and EJB 3.0 specs
The Java Persistence API spec (JPA 1.0) is actually a separate and distinct spec from EJB 3.0, and EJB 3.0 refers to JPA for its POJO persistence model. One reason the two were separated into individual specs (though produced by the same expert group) was precisely so JPA could become part of JavaSE at some point. (There was a very conscientous effort to make sure that JPA, as defined in the spec, could be used in either SE or EE environments.) It also helps separate the concepts of the persistence model (JPA) from the component execution model (EJB3). This is good, since these two models being smashed together in EntityBeans was one of the factors EB's started to be viewed as 'heavyweight'.
Randy Schnier IBM, member JSR 220 expert group
|
|
Message #192878
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Article vs. Hibernate EJB3?
I have implemented an EJB3 persistence unit, I've read most of the released documents regarding EJB3 persistence, from both Sun and JBoss, and I have these comments.
1. Very nice, clear and helpful article. Thank you Sanjeeb.
2. Hibernate-EJB3 docs reference a ".ejb3" file which encompasses the persistence unit. Sanjeeb implies this file can be in a simple .jar file. Let me say "massive thank you" to whoever is responsible, if in fact EJB3s can be captured in a simple JAR. The packaging issues for ".ejb3" were going to be pretty annoying.
3. The em.find method was not well documented in Hibernate-EJB3 docs, so it was nice to see it used here.
4. I didn't know that @Id was required, and that it was mentioned in the article saved me some time.
5. Just a plug for the Hibernate-EJB3 folks: That microcontainer is way-nice for debugging these EJB3 entity beans.
What can we do to encourage the release of this great persistence technology?
|
|
Message #192879
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
How to enable Java2DB feature in glassfish?
In my original posting, I mentioned that because of a bug, Java2DB (i.e. automatic table creation during deployment) feature does not work in glassfish for Derby database. Very soon, the bug is going to be fixed. It is right now only working for Oracle database. To enable it, either
1) add a property in persistence.xml under <properties> tag as follows: <property name="ddl-generation" value="createtables"/>
OR
2) Invoke asadmin deploy command with an additional option -createtables=true. So the complete command is:
$GLASSFISH_HOME/bin/asadmin deploy --user <username> --password <password> --createtables=true <path to jar/war/ear>
Watch out for updates at Persistence RI project page to know when this feature is available for all databases.
--Sahoo
|
|
Message #192890
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
JPA 1.0 and EJB 3.0 specs
Hey, the name EJB3 has been overly sold to the developer community as the POJO persistence solution for so long, it is too late to correct the mistake. Even though the acronym POJO itself was coined by Martine Fowler et al to make using plain Java object instead of heavyweight EJB more sexy (thus more attractive to developers who want to be sexy).
|
|
Message #192891
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
JPA 1.0 and EJB 3.0 specs
Especially when this is not in the interest of some "EJB3 vendors" (to give the stuff a proper name).
|
|
Message #192892
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
JPA 1.0 and EJB 3.0 specs
Even though the acronym POJO itself was coined by Martine Fowler et al to make using plain Java object instead of heavyweight EJB more sexy (thus more attractive to developers who want to be sexy). Five years ago!
|
|
Message #192929
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
JPA 1.0 and EJB 3.0 specs
Hey, the name EJB3 has been overly sold to the developer community as the POJO persistence solution for so long, it is too late to correct the mistake. OTOH POJO persistence has been oversold, too. After having to choose between 5+ MB of generated SQL queries or writing a separate finder for each access case in a proprietary language with shabby tool support, plain old SQL doesn't look that bad anymore.
|
|
Message #192950
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Re: Article vs. Hibernate EJB3?
For what it's worth, I meant ".par" not ".ejb3".
QUESTION: Is it true that ".par" is no longer necessary to indicate a persistence archive? (Please.) The presence of a persistence.xml file should be enough to trigger examining annotations, and the extra deployment complexity of dealing with .par using Maven, etc. will hinder adoption.
|
|
Message #192957
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Article vs. Hibernate EJB3?
Thank you, Dan. You possess great moral codes to approach authors. Not everyone possesses what you do in this direction.
You illustrated a good method when publishing. I wish, we all illustrate the same (good method) (here on TSS) when posting questions.
Good.
|
|
Message #192984
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Re: Article vs. Hibernate EJB3?
QUESTION: Is it true that ".par" is no longer necessary to indicate a persistence archive? (Please.) The presence of a persistence.xml file should be enough to trigger examining annotations, and the extra deployment complexity of dealing with .par using Maven, etc. will hinder adoption. This is correct. ".par" as a packaging identifier was proposed in one of the earlier versions of the spec, but in the latest spec version, any .jar file containing a persistence.xml file identifies to the EE runtime that the .jar should be examined for entity annotations and xml persistence attributes. (The persistence.xml file identifies which classes within the .jar belong to each Persistence Unit defined for that jar.) In an SE environment, the classes that define the persistence unit are identified to the EntityManager through config parms passed in when the EntityManager is created.
Randy
|
|
Message #193014
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Article vs. Hibernate EJB3?
Thank you, Dan. You possess great moral codes to approach authors. Not everyone possesses what you do in this direction.You illustrated a good method when publishing. I wish, we all illustrate the same (good method) (here on TSS) when posting questions.Good. What are you the TTS etiquette cheer learder?
|
|
Message #193030
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Article vs. Hibernate EJB3?
Some comments online
2. Hibernate-EJB3 docs reference a ".ejb3" file which encompasses the persistence unit. Sanjeeb implies this file can be in a simple .jar file. Let me say "massive thank you" to whoever is responsible, if in fact EJB3s can be captured in a simple JAR. The packaging issues for ".ejb3" were going to be pretty annoying. This is already (and has always been) implemented in Hibernate Entity Manager (ie the simple jar stuff). I should make it clearer from the doc.
3. The em.find method was not well documented in Hibernate-EJB3 docs, so it was nice to see it used here. I don't see much more than UserCredential credential = em.find(UserCredential.class, name); in Sanjeeb article which is more or less the same kind of information that in HEM docs? http://www.hibernate.org/hib_docs/entitymanager/reference/en/html_single/#d0e499
What kind of information were you expecting? Any proposal welcome :-)
4. I didn't know that @Id was required, and that it was mentioned in the article saved me some time. A property(ies) holding the id is required, not @Id (in the last public spec). You can have @Id / @EmbeddedId on a property or even @IdClass at the class level
Emmanuel
|
|
Message #193032
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Re: Article vs. Hibernate EJB3?
QUESTION: Is it true that ".par" is no longer necessary to indicate a persistence archive? (Please.) The presence of a persistence.xml file should be enough to trigger examining annotations, and the extra deployment complexity of dealing with .par using Maven, etc. will hinder adoption. This is correct. ".par" as a packaging identifier was proposed in one of the earlier versions of the spec, but in the latest spec version, any .jar file containing a persistence.xml file identifies to the EE runtime that the .jar should be examined for entity annotations and xml persistence attributes. (The persistence.xml file identifies which classes within the .jar belong to each Persistence Unit defined for that jar.) In an SE environment, the classes that define the persistence unit are identified to the EntityManager through config parms passed in when the EntityManager is created.Randy
Is this also true for the .ejb3 suffix for Session Beans? Does JBoss support .jar suffix for EJB3 Session Beans? Let me continue this highly moral author trend and say that I declare my undying love to those responsible, if .jar is a fine suffix for EJB3 Session Beans!
|
|
Message #193049
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Java2DB feature now supported for all databases in glassfish
The bug that Sahoo had mentioned earlier has been resolved. Effective from todays build glassfish would have support for java2db for different databases.
|
|
Message #193056
Post reply
Post reply
Post reply
Go to top
Go to top
Go to top
|
 |
Is .jar enough or do I need .par & .ejb3 etc?
Is this also true for the .ejb3 suffix for Session Beans? Yes, it is true for EJB3 session beans as well. It is implemented in glassfish project. .ejb3 was always a JBoss specific thing, never got into the spec. .par was introduced in the EJB3 spec. But it was subsequently removed.
--Sahoo
|
|
 |
New content on TheServerSide.comNew content on TheServerSide.comNew content on TheServerSide.com |
 |
 |
Reza Rahman explores the features of the proposed JSR 299, Contexts and Dependency Injection for Java EE (CDI). When approved, it promises to be a key feature of Java EE 6.
(November 2, Article)
SAML is an XML-based standard for exchanging authentication and authorization data between security domains. The single most important problem that SAML was created to solve is the Web browser Single Sign-On problem. Many organizations are debating whether to stay with version 1.1 or move to 2.0. This article makes observations about both options.
(September 28, Article)
Joe Ottinger takes a look at how people learn, and applies it to the practice of programming. He notes that understanding how people learn is an essential part of working in a programming team.
(September 22, Article)
Stephen Maryka gave us an article about the Asynchronous Web and posed a number of questions that get examined like an approach to delivering Asynchronous Web capabilities through extensions to existing Java EE technologies.
(July 14, Article)
JavaServer Faces Flex goal is to provide users capability in creating standard Flex components, part of flexSDK which is open sourced through MPL license, as normal JSF components. This article by Ji Hoon Kim will provide an overview of creating a simple multilingual JSF page consisting of JSF Flex tags.
(June 29, Article)
In this session Jeff explores the key characteristics of successful SOA projects. He covers some of the patterns, and anti-patterns, tool sets, and strategies that he himself learned the hard way. Last, he provides a strategy and blueprint for achieving a high likelihood of success in your SOA project.
(June 23, Tech Talk)
Ari Zilka, CTO of Terracotta, Inc., talks about the new features in Terracotta 3.1, announced during JavaOne and available now.
(June 15, Tech Talk)
In this Tech Talk, Josh Long explores an integration challenge using Spring Integration and walks through the implementation, employing and expanding on the basic patterns of Enterprise Application Integration to tie together components into a function integration solution, and then demonstrates how Spring Integration helps address the integration requirements.
(June 15, Tech Talk)
In this Tech Talk, David Geary teaches you: The basics of Google Web Toolkit; How to implement Ajax-enabled applications in Java; Internationalization; Hooking into the browser history mechanism; Remote procedure calls.
(June 4, Tech Talk)
Jon Kern discusses the best architecture/technical solutions and ensure that they are repeated by all developers. By tackling the architecture up-front in a serial manner, subsequent parallel development will be much more manageable and predictable.
(May 28, Tech Talk)
This keynote describes the frustrations of modern knowledge workers in their quest to actually get some work done, and solutions for how to guard yourself against all those distractions. Neal Ford talks about environments, coding, acceleration, automation, and avoiding repetition as ways to defeat the misguided attempts to sap your ability to produce good work.
(May 26, Tech Talk)
Gil demonstrates how new, aggressive uses of already abundant compute capacity by common applications offer competitive value for application designers.
(May 21, Tech Talk)
Chris Keene introduces WaveMaker as a new way to automate the ability to generate Hibernate classes in order to more quickly bring OR mapping into an application.
(May 19, Article)
In this session Nati Shalom demonstrates how to take a standard Java EE web application and scale it out or down dynamically without changes to the application code. Seeing as most web applications are over-provisioned to meet infrequent peak loads, this is a dramatic change because it enables growing your application as needed, when needed, without paying for unutilized resources.
(May 19, Tech Talk)
Mastering EJB was one of the original and most influential EJB books in the industry. Mastering EJB III now returns with two new expert co-authors, updated for EJB 2.1 and 30% new chapters including security, integration, best practices, open source, and more.
(Book PDF Download)
The Application Server Matrix is a detailed listing of J2EE vendors and their application server products, with information on latest version numbers, J2EE spec support and licensing, pricing, platform support, and links to product downloads and reviews.
(Application Server Comparison Matrix)
|
|