-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Empty Constructor
PostPosted: Mon May 23, 2005 10:05 am 
Regular
Regular

Joined: Fri Feb 25, 2005 3:02 am
Posts: 71
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version:3.0[/b]

[b]Mapping documents:[/b]

[b]Code between sessionFactory.openSession() and session.close():[/b]

[b]Full stack trace of any exception that occurs:[/b]

[b]Name and version of the database you are using:[/b]

[b]The generated SQL (show_sql=true):[/b]

[b]Debug level Hibernate log excerpt:[/b]


Should we always need to have an empty constructor in our POJOs. If yes, why?

thanks in advance


Top
 Profile  
 
 Post subject: Re: Empty Constructor
PostPosted: Tue May 24, 2005 5:10 pm 
Newbie

Joined: Fri Aug 13, 2004 12:25 pm
Posts: 7
Location: Boston
Yes, you do. Othewise, how would Hibernate create an instance of you object? Hibernate uses the following to create a transient instance:

Class cls = Class.forName("<name-of-class>");
...
Object obj = cls.newInstance();

In order to be able to run cls.newInstance(), there must be an empty constructor.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 24, 2005 5:47 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
Actually, you either need an empty constructor or provide an Interceptor implementation that knows how to construct your objects.

I believe you'll also run into issues if you attempt to proxy an object that doesn't have a default constructor.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


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

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.