-->
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: Problem when entity is saved ...
PostPosted: Thu Feb 12, 2009 7:18 am 
Beginner
Beginner

Joined: Wed Jan 28, 2009 10:16 am
Posts: 37
Hello,

I have a @Entity (Class Dossier) and this entity owns others one like an @Entity Adress object or other like Vehicle...

My problem is that when I try to save my Dossier with :
System.out.println("Save Dossier");
Session session = HibernateUtil.getSession();
Transaction transaction = session.beginTransaction();
session.saveOrUpdate(dossier);
transaction.commit();
session.close();

I have only the primitif type that are saved.... ?

And I have a id in my Dossier class like this :
Code:
@Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   private Integer id;


But when I look into my data base, the id is 1
But the sql query on my log is the following :
Code:
Save Dossier
11:54:26,614 DEBUG SQL:111 - update Dossier set etatDossier=? where id=?
Hibernate: update Dossier set  etatDossier=? where id=?
11:54:26,614 DEBUG SQL:111 - delete from Dossier_Document where Dossier_id=?
Hibernate: delete from Dossier_Document where Dossier_id=?
11:54:26,614 DEBUG SQL:111 - delete from Dossier_protagonistes where Dossier_id=?
Hibernate: delete from Dossier_protagonistes where Dossier_id=?


Have you an idea of the origin of this problem ?
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2009 7:38 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Louevie wrote:
I have only the primitif type that are saved.... ?

Do you mean that when you save your dossier entity the related entities are not saved? For that you will have to include cascade=CascadeType.SAVE_UPDATE in the ManyToOne mapping

And about the delete statements which are there in the log file we have to look at the entity mappings and the code by which you create the dossier object to know whats going wrong.

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2009 8:29 am 
Beginner
Beginner

Joined: Wed Jan 28, 2009 10:16 am
Posts: 37
Ok, I will look that...
For my related entities, the annotation that I use are :
@CollectionOfElements


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.