-->
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: Using persistance class without blank constructor
PostPosted: Thu Mar 24, 2005 11:29 am 
Newbie

Joined: Thu Mar 24, 2005 11:24 am
Posts: 1
Hi,

I have come up with a situation where I have a class which does not contain any blank constructor and setter getter methods. Becuase it does not make sense to create an object of that class with blank constructor. It is a business specific requirement.

Now I have to persist that class in a table. Is there a way we can do this? Because Hibernate 2 says that we should have a blank constructor with setter and getter methods.


Top
 Profile  
 
 Post subject: Re: Using persistance class without blank constructor
PostPosted: Sun Mar 27, 2005 4:57 am 
Senior
Senior

Joined: Sat Jul 17, 2004 5:16 pm
Posts: 143
talktopraveenkumar wrote:
Hi,

I have come up with a situation where I have a class which does not contain any blank constructor and setter getter methods. Becuase it does not make sense to create an object of that class with blank constructor. It is a business specific requirement.

Now I have to persist that class in a table. Is there a way we can do this? Because Hibernate 2 says that we should have a blank constructor with setter and getter methods.


I believe the reason is that it is constructed that way with reflection by hibernate. Check out where this occurs in Hibernate's code to see if there is a way around it... Do you create it with a factory, or a constructor with multiple arguments? I would just subclass it and give it a default constructor... anyone correct me if there is a way.

Chris


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 27, 2005 6:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
sorry not really possible.

hibernate does not know all the values of the object when it instantiates a new object.

but your constructor does not need to be public, it can be package protected - and you can also instantiate your own objects based on an id via Interceptor.instantiate()

_________________
Max
Don't forget to rate


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.