NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Hibernate and Modules ...

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users
View previous topic :: View next topic  
Author Message
JavaMan55



Joined: 27 Dec 2010
Posts: 18

PostPosted: Sun Jan 09, 2011 2:30 am    Post subject: Hibernate and Modules ... Reply with quote

I decided that for one of my applications I wanted to put the date access into it's own module. I am using Hibernate. This is going to be a large refactoring of an existing project to use Hibernate rather than a "home-grown" data access layer

Discovering that I can't really create a Hibernate project within a module directly, I have created a Java Project and created the requisite Hibernate config files and supporting class files.

To test this, I have also created a main method and class and this project works just perfectly in standalone mode (no GUI, just an output to the console of what the test queries return)

Now I jar it up and then put it into a Wrapper Module and create dependencies in my main project. When I hook it in, so that one of the queries is used, I get a class not found error - the class it can't find? HibernateException!

All my own code in the Hibernate module is visible to the places that I make the calls to it, but if I attempt to instantiate a HibernateException ("throw new HibernateException();"), the alt-enter help doesn't present an "Add import for..." option. I have attempted to include the hibernate jars in the jar for the module, but that doesn't seem to work either.

Any help or pointing to links is appreciated
Back to top
JavaMan55



Joined: 27 Dec 2010
Posts: 18

PostPosted: Sun Jan 09, 2011 4:02 am    Post subject: Reply with quote

A bit more info on this ...

I get the following when attempting to build the main Module suite:

org.myorg.kshibernate.HibernateUtil cannot access org.hibernate.SessionFactory

I am certain it has to be because the depended upon libs are not in the right location ... but how to ensure that they are in the right place has be a bit baffled.

Thanks
Back to top
Christian G.



Joined: 02 Dec 2010
Posts: 12
Location: Berlin, Germany

PostPosted: Sun Jan 09, 2011 12:28 pm    Post subject: Reply with quote

Hi,

don't know if this is your problem, but does your persistence.xml know all your classes you want to persist?

like:

Code:

...
<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">

<class>your.package.namespace.YourClass1</class>
<class>your.package.namespace.YourClass2</class>

<properties>
...


Don't know for sure, but i think hibernate can't automatically detect classes in other modules.
Back to top
JavaMan55



Joined: 27 Dec 2010
Posts: 18

PostPosted: Sun Jan 09, 2011 5:49 pm    Post subject: Reply with quote

Christian G. wrote:
Hi,

don't know if this is your problem, but does your persistence.xml know all your classes you want to persist?

like:

Code:

...
<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">

<class>your.package.namespace.YourClass1</class>
<class>your.package.namespace.YourClass2</class>

<properties>
...


Don't know for sure, but i think hibernate can't automatically detect classes in other modules.


Hmmm ... I don't know - I'll have to go check it. However, I think I might put this on the back burner for now and simply incorporate the Hibernate stuff directly into the main module where most of the data layer is now, just to get it working with hibernate.

When I have a few moments I will try this, tho, it could save me some agony later.

Thanks
Back to top
Monezz



Joined: 18 Feb 2009
Posts: 254

PostPosted: Mon Jan 10, 2011 11:17 pm    Post subject: [platform-dev] Re: Hibernate and Modules ... Reply with quote

On Sun, Jan 9, 2011 at 5:03 AM, JavaMan55 <address-removed> wrote:
Quote:
A bit more info on this ...

I get the following when attempting to build the main Module suite:

org.myorg.kshibernate.HibernateUtil cannot access org.hibernate.SessionFactory

I am certain it has to be because the depended upon libs are not in the right location ... but how to ensure that they are in the right place has be a bit baffled.


Did you set the hibernate packages as public packages in the library wrapper?
If you are using jpa, you will have to include the
hibernate-entitymanager library aswell.
Back to top
johnphilipsolano



Joined: 29 Nov 2010
Posts: 11
Location: 175

PostPosted: Tue Jan 11, 2011 6:35 am    Post subject: Reply with quote

When your tables keeps on changing, it's a hassle to use JPA in the platform. I do hope they'll create a project template, something like a "JPA Entity Classes Module", from where we can update entity classes without having to explicitly wrap them up. (I think I'm not at the right place to suggest a feature.) Confused
Back to top
JavaMan55



Joined: 27 Dec 2010
Posts: 18

PostPosted: Tue Jan 11, 2011 8:44 pm    Post subject: Reply with quote

johnphilipsolano wrote:
When your tables keeps on changing, it's a hassle to use JPA in the platform. I do hope they'll create a project template, something like a "JPA Entity Classes Module", from where we can update entity classes without having to explicitly wrap them up. (I think I'm not at the right place to suggest a feature.) Confused


Well, IMHO, that would be avoided if a "Clean/Build" or "Build All" would actually build "all" - or even if when you built the underlying library, it would propagate to the library wrapper. or I could even live with "rebuilding" the library wrapper and having it simply suck in a fresh copy of the library from the underlying project (of course, you'd have to have rebuilt it there, too)

I tried a few things last night and discovered that none of the above actually works. The only place the newly rebuilt library is found is in the /dist directory of the original project. Unless I messed up somehow.

Still fighting with both Hibernate, and EclipseLink!
Back to top
Monezz



Joined: 18 Feb 2009
Posts: 254

PostPosted: Wed Jan 12, 2011 9:33 am    Post subject: [platform-dev] Re: Hibernate and Modules ... Reply with quote

On Tue, Jan 11, 2011 at 9:45 PM, JavaMan55 <address-removed> wrote:
Quote:

johnphilipsolano wrote:
Quote:
When your tables keeps on changing, it's a hassle to use JPA in the platform. I do hope they'll create a project template, something like a "JPA Entity Classes Module", from where we can update entity classes without having to explicitly wrap them up. (I think I'm not at the right place to suggest a feature.) Confused

Currently I am using hibernate(jpa) in my platform project.
The only thing I need to do when I add a new entity is adding it to
the persistence.xml aswell.


Quote:

Well, IMHO, that would be avoided if a "Clean/Build" or "Build All" would actually build "all" - or even if when you built the underlying library, it would propagate to the library wrapper.
Back to top
sahar_ad



Joined: 04 Jul 2012
Posts: 11

PostPosted: Sun Jul 08, 2012 9:57 am    Post subject: Reply with quote

Hi

where is persistence.xml to register my class?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo