-->
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.  [ 1 post ] 
Author Message
 Post subject: error unknown entity when calling session.save(this)
PostPosted: Mon Nov 06, 2006 5:14 am 
Newbie

Joined: Mon Nov 06, 2006 4:33 am
Posts: 1
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??


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

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.