-->
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: Hibernate 3.5 @OneToOne EntityManager find() returns null
PostPosted: Thu Sep 02, 2010 11:29 am 
Newbie

Joined: Thu Sep 02, 2010 11:12 am
Posts: 2
I think I found a bug in Hibernate 3.5, because the code above works in 3.2.2 branch.
Whenever I have a @OneToOne relation in this fashion, entityManager is not able to find the entity. The find() method allways return null!!!!!!

Code:
@Entity
@Table(name = "cheque")
@TableGenerator(name = "chequeTG", table = "sequenciador", pkColumnName = "tabela", valueColumnName = "valor", allocationSize = 1)
public class Cheque implements Serializable {

   /**
    *
    */
   private static final long serialVersionUID = 1L;

   @Id
   @GeneratedValue(strategy = GenerationType.TABLE, generator = "chequeTG")
   @Column(name = "id", nullable = false)
   private Long id;

               ..............

   [color=#800000]@OneToOne(cascade={CascadeType.ALL},optional=true)
   @PrimaryKeyJoinColumn(name="id",referencedColumnName="cheque_id")
   private ChequeUso uso[/color];
               ..................         
}
@Entity
@Table(name="cheque_uso")
public class ChequeUso implements Serializable {

   /**
    *
    */
   private static final long serialVersionUID = 1L;

   @Id
   @Column(name="cheque_id")
   private Long id;
   
   @ManyToOne
   @JoinColumn(name="consumo_id")
   private Consumo consumo;
   
   @OneToOne
   @JoinColumn(name="cheque_id")
   private Cheque cheque;
   
   @Column(name = "cheque_uso_valor")
   private double usado;
}



em.find(Cheque.class, 1L) // always return null

If I remove the @OneToOne relation, find() return the entity.

This didnĀ“t happen with Hibernate 3.2.2.


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.