[jboss-user] [EJB 3.0] - Re: Unknown error

fhh do-not-reply at jboss.com
Wed May 2 16:29:45 EDT 2007


Well, either it is a primary key then the constraint is that its unique and not null. Or it is a foreign key so that it is either null or refers to a row in the related table.

What is Hibernate supposed to do, if you set the user details to null? Then you would also assign null to the primary key which is not allowed.

Second problem: If you assign a new user details bean to the user bean you would also change the pk of the user bean that doesn't make sense.

So I doubt this would have ever worked. Simply try the @PrimaryKeyJoinColumn. In theory it should do exactly what you want to do.

Try this:


  | @Entity
  | @Table(name="usuario")
  | public class UsuarioEJB { 
  | 
  |    private Integer id;
  |    private UsuarioDetallesEJB usuarioDetallesEJB ;
  |    
  |    @Id
  |    @Column(name="idUsuario")
  |    public Integer getId() {
  | 
  |        return this.id;
  | 
  |    }
  | 
  |    // setter
  | 
  |   @OneToOne
  |   @PrimaryKeyJoinColumn
  |   public UsuarioDetallesEJB getUsuarioDetallesEJB() {
  | 
  |      return this.id;
  | 
  |   }
  | 
  |   //setter
  | 
  | }
  | 

Regards

Felix


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4042619#4042619

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4042619



More information about the jboss-user mailing list