Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » JPA, using it, and XML mappings.
JPA, using it, and XML mappings. [message #226054] Tue, 06 January 2009 22:13 Go to next message
Graham Reeds is currently offline Graham ReedsFriend
Messages: 11
Registered: July 2009
Junior Member
I hope some of you can help me. I know this is only partially to do with
Eclipse but it does have ramifications on using it.

I am working from this tutorial on ibm.com:
http://www.ibm.com/developerworks/edu/os-dw-os-eclipse-europ a1.html

Now enough things had changed between Europa and Ganymede to give up and
download Europa instead and work from there. I tried varying installs of
JDK and JEE - thinking that the JEE would include the persistence.

However it turns out you need to get a copy of JPA from the Glassfish
project and install that. I used
glassfish-persistence-installer-v1_ur1-b14.jar.

This allows me to use the JPA and get the mappings, but OpenJPA is not
needed. When configuring the jpa library I found I only need to list the
toplink and toplink-essentials jars. Where does OpenJPA come into this? If
I use just OpenJPA on it's own then it complains that it can't find
javax.persistence.

That's my first problem. Where does OpenJPA fit into this? Also if I have
to use the glassfish release, where does Dali fit into this?

The second problem is that the tutorial says that JPA will add the
necessary xml to persistence.xml. However in my instance it hasn't done.
This would suggest that the version I use is not the same as the author's,
though I thought I got the last release of Europa. Can someone shed some
light on this?

Thanks, Graham Reeds
Re: JPA, using it, and XML mappings. [message #226139 is a reply to message #226054] Wed, 07 January 2009 15:00 Go to previous messageGo to next message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 470
Registered: July 2009
Senior Member
Graham Reeds wrote:

> I hope some of you can help me. I know this is only partially to do with
> Eclipse but it does have ramifications on using it.

> I am working from this tutorial on ibm.com:
> http://www.ibm.com/developerworks/edu/os-dw-os-eclipse-europ a1.html

> Now enough things had changed between Europa and Ganymede to give up and
> download Europa instead and work from there. I tried varying installs of
> JDK and JEE - thinking that the JEE would include the persistence.

This tutorial does not appear to use JEE, looking at the prerequisites
list. All you need is a regular Java SE JDK, Tomcat, the DB, and a JPA
implementation. This tutorial calls for the OpenJPA implementation.
Contained in the OpenJPA libraries will be the javax.persistence classes
you are looking for. When creating a JPA project you will want to create
a User Library that contains the OpenJPA jar(s) that contains the
javax.persistence classes. This User Library should then be added to the
the JPA project via the New JPA Project Wizard, or just manually (if you
have already created a project).

> However it turns out you need to get a copy of JPA from the Glassfish
> project and install that. I used
> glassfish-persistence-installer-v1_ur1-b14.jar.

You don't need this for the referenced tutorial. The JPA implementation
is in OpenJPA.

> This allows me to use the JPA and get the mappings, but OpenJPA is not
> needed. When configuring the jpa library I found I only need to list the
> toplink and toplink-essentials jars. Where does OpenJPA come into this? If
> I use just OpenJPA on it's own then it complains that it can't find
> javax.persistence.

See above comments.

> That's my first problem. Where does OpenJPA fit into this? Also if I have
> to use the glassfish release, where does Dali fit into this?

See above comments. Dali is just the tooling inside Eclipse, and does
not contain any JPA implementation, as you have seen.

> The second problem is that the tutorial says that JPA will add the
> necessary xml to persistence.xml. However in my instance it hasn't done.
> This would suggest that the version I use is not the same as the author's,
> though I thought I got the last release of Europa. Can someone shed some
> light on this?

I'm not sure what the necessary xml is that you are referring to, but it
will create a template persistence.xml file that you can use as a starting
point. In Ganymede, there is a full persistence.xml editor included in
Dali.

> Thanks, Graham Reeds

Please see the Dali website for links to tutorials, docs, etc, for working
with JPA.

http://www.eclipse.org/webtools/dali/main.php

Also, in the case you were using a JEE server (such as Glassfish) you
would define this as a Target Server in New JPA wizard. A JEE
implementation is specified differently than a JRE/JDK.


Hope this helps,

Neil Hauge
Re: JPA, using it, and XML mappings. [message #226183 is a reply to message #226139] Wed, 07 January 2009 23:27 Go to previous messageGo to next message
Graham Reeds is currently offline Graham ReedsFriend
Messages: 11
Registered: July 2009
Junior Member
> This tutorial does not appear to use JEE, looking at the prerequisites
> list. All you need is a regular Java SE JDK, Tomcat, the DB, and a JPA
> implementation. This tutorial calls for the OpenJPA implementation.
> Contained in the OpenJPA libraries will be the javax.persistence classes
> you are looking for. When creating a JPA project you will want to create
> a User Library that contains the OpenJPA jar(s) that contains the
> javax.persistence classes. This User Library should then be added to the
> the JPA project via the New JPA Project Wizard, or just manually (if you
> have already created a project).

This is what I did:
All the necessary javax.persistence.* are MIA: e.g: The import
javax.persistence.Column cannot be resolved

Right click on project->Build Path->Add Libraries. Select User Library.
Click User Libraries. Click New, type OpenJPA and then Add Jars. Select
openjpa-1.0.1.jar. Result: javax.persistence.* are still missing.

Here's my results:
I tried with JDK + OpenJPA: It didn't work.
I tried with JEE + OpenJPA: It didn't work.
I tried with JEE + Glassfish: It worked - no OpenJPA needed.
I tried with JDK + Glassfish: It worked - no OpenJPA needed.

The pre-requisites has
http://java.sun.com/javaee/technologies/persistence.jsp listed. The text
implies that it is needed.

> You don't need this for the referenced tutorial. The JPA implementation
> is in OpenJPA.

But it isn't - my tests show that. I've retried (to get the exact text and
steps required) and it still doesn't work.

> See above comments. Dali is just the tooling inside Eclipse, and does
> not contain any JPA implementation, as you have seen. On

> I'm not sure what the necessary xml is that you are referring to, but it
> will create a template persistence.xml file that you can use as a starting
> point. In Ganymede, there is a full persistence.xml editor included in
> Dali.

The text refers to the persistence.xml and the article has a picture and
text to that implies that the JPA tools will write the XML for you (or at
least give you a "leg up").

> Please see the Dali website for links to tutorials, docs, etc, for working
> with JPA.

> http://www.eclipse.org/webtools/dali/main.php

> Also, in the case you were using a JEE server (such as Glassfish) you
> would define this as a Target Server in New JPA wizard. A JEE
> implementation is specified differently than a JRE/JDK.

I couldn't comment on that - my first language isn't Java. This is why I
am confused by the article compared to what is actually happening here.

I am working from this tutorial. I will have to check out Dali at
somepoint in the future.

Thanks, Graham Reeds
Re: JPA, using it, and XML mappings. [message #226189 is a reply to message #226183] Thu, 08 January 2009 04:51 Go to previous message
Eclipse UserFriend
Originally posted by: first.last.oracle.com

Hi, Graham.

I haven't tried the tutorial directly; but maybe this will help:

I believe the tutorial skips a critical step: Configuring
the "openjpa" User Library selected as the Default JPA
Implementation Library in Figure 30. This library
should contain several of the JARs found in the OpenJPA
download zip[1], not *just* the openjpa JAR:

1. ./openjpa-1.0.1.jar
2. the JARs in the ./lib directory (actually, I
don't think you need them *all* for Java SE, but it
probably won't hurt)

../lib/geronimo-jpa_3.0_spec-1.0.jar contains the
javax.persistence classes you are looking for; the other
JARs are needed by OpenJPA to execute at runtime. I couldn't
find any documentation of this on the Apache OpenJPA web site -
all I stumbled across was a newsgroup-like posting saying:
"That would be a Good Idea...." Oh well....

Also, the portions of the tutorial that discuss mapping classes
to database tables (on page 5) is making use of "Dali".
Dali is a sub-project (or something like that) of WTP; and
WTP (including Dali) is what you get when you download
"Eclipse IDE for Java EE Developers".
So, if you have that download, you should be able to use the
Dali tutorials Neil mentioned.

Let us know if this helps.
Brian

[1] http://archive.apache.org/dist/openjpa/1.0.1/apache-openjpa- 1.0.1-binary.zip

Graham Reeds wrote:
>> This tutorial does not appear to use JEE, looking at the prerequisites
>> list. All you need is a regular Java SE JDK, Tomcat, the DB, and a
>> JPA implementation. This tutorial calls for the OpenJPA
>> implementation. Contained in the OpenJPA libraries will be the
>> javax.persistence classes you are looking for. When creating a JPA
>> project you will want to create a User Library that contains the
>> OpenJPA jar(s) that contains the javax.persistence classes. This User
>> Library should then be added to the the JPA project via the New JPA
>> Project Wizard, or just manually (if you have already created a project).
>
> This is what I did:
> All the necessary javax.persistence.* are MIA: e.g: The import
> javax.persistence.Column cannot be resolved
>
> Right click on project->Build Path->Add Libraries. Select User Library.
> Click User Libraries. Click New, type OpenJPA and then Add Jars. Select
> openjpa-1.0.1.jar. Result: javax.persistence.* are still missing.
>
> Here's my results:
> I tried with JDK + OpenJPA: It didn't work.
> I tried with JEE + OpenJPA: It didn't work.
> I tried with JEE + Glassfish: It worked - no OpenJPA needed.
> I tried with JDK + Glassfish: It worked - no OpenJPA needed.
>
> The pre-requisites has
> http://java.sun.com/javaee/technologies/persistence.jsp listed. The text
> implies that it is needed.
>
>> You don't need this for the referenced tutorial. The JPA
>> implementation is in OpenJPA.
>
> But it isn't - my tests show that. I've retried (to get the exact text
> and steps required) and it still doesn't work.
>
>> See above comments. Dali is just the tooling inside Eclipse, and
>> does not contain any JPA implementation, as you have seen. On
>
>> I'm not sure what the necessary xml is that you are referring to, but
>> it will create a template persistence.xml file that you can use as a
>> starting point. In Ganymede, there is a full persistence.xml editor
>> included in Dali.
>
> The text refers to the persistence.xml and the article has a picture and
> text to that implies that the JPA tools will write the XML for you (or
> at least give you a "leg up").
>
>> Please see the Dali website for links to tutorials, docs, etc, for
>> working with JPA.
>
>> http://www.eclipse.org/webtools/dali/main.php
>
>> Also, in the case you were using a JEE server (such as Glassfish) you
>> would define this as a Target Server in New JPA wizard. A JEE
>> implementation is specified differently than a JRE/JDK.
>
> I couldn't comment on that - my first language isn't Java. This is why I
> am confused by the article compared to what is actually happening here.
>
> I am working from this tutorial. I will have to check out Dali at
> somepoint in the future.
>
> Thanks, Graham Reeds
>
Previous Topic:dynamic web project
Next Topic:Format javascript source code before save
Goto Forum:
  


Current Time: Sun Nov 23 21:19:05 GMT 2014

Powered by FUDForum. Page generated in 0.01635 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software