Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3
when I using session.save() method inside an entity method which is intended to be persisted by hibernate an error ocures.
when I call session.save() outside this method everything is ok.
consider the event class example wich is disscussed in hibernate reference documentation.I want to have a method named create() inside this class.
I want when I call create method of event class,it is persisted by hibernate.
for doing this I have the below psudo code
class event{
//properties and getter setters
public void create(){
mysession=get session factory();
mysession.save(this); //here I got error
}
you see when Inside this method I create another instance of event class and call mysession.save(myevent) everything is ok!
for example somthing like this
class event{
//properties and getter setters
public void create(){
event myevent=new event();
//here populate myevent properties
mysession=get session factory();
mysession.save(myevent); //here every thing is ok
}
as I want to adapt hibernate into an enterprise application with previously defined and implemented architecture, I need to have such create method which is described first.
I wonder IF we can persisit an object by calling a method defined inside thet object or not.
very pleased if anyone may help me??