-->
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.  [ 2 posts ] 
Author Message
 Post subject: Relationen mitspeichern
PostPosted: Sat Feb 03, 2007 7:23 am 
Newbie

Joined: Sun Apr 16, 2006 1:02 pm
Posts: 12
Hibernate version:

3.2

Hallo, 2 simple Entitaeten: Urls und GzHtml (gzipter HTML code):
Code:
public class Urls
{
   @Id
   @GeneratedValue( generator = "hibernate-uuid" )
   private String id;

   @Column( name = "url" )
   private String url;

   @OneToOne
   @PrimaryKeyJoinColumn
   private GzHtml gzHtml;

Code:
public class GzHtml
{
   @Id
   @Column( name = "url_id" )
   private String urlId;

   @Column( name = "html" )
   private byte[] html;


Und wenn ich das jetzt mache, speichert er nur Urls:

Code:
      Urls u = new Urls();
      u.setUrl( url.toString() );
      
      GzHtml h = new GzHtml();
      h.setHtml( Utility.compress( html ) );

      u.setGzHtml( h );
      session.save( u );


Wieso? Wie macht man's richtig?


Top
 Profile  
 
 Post subject: re: Relationen mitspeichern
PostPosted: Sun Feb 04, 2007 10:44 am 
Newbie

Joined: Wed Dec 06, 2006 5:45 pm
Posts: 3
du muss über cascade die Operationen definieren, die auf das referenzierte Objekt angewendet werden sollen.

Ich glaube mit hibernate annotations sieht das zB in etwas so aus

Code:
@OneToOne(cascade = CascadeType.ALL)
...


Stefan


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.