-->
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: NPE hbm2ddl 3.1.0.alpha5
PostPosted: Thu Sep 22, 2005 11:17 am 
Newbie

Joined: Thu Sep 22, 2005 10:34 am
Posts: 1
Hibernate version:
Hibernate tools 3.1.0.alpha5
Hibernate Annotations 3.1 beta 5
Hibernate 3.1 beta 3
Derby 10.1.1.0

Hi All,
I have a problem with HibernateToolTask 3.1.0 alpha 5 when used Annotations 3.1 beta 5. Adding a mappedBy attribute to a @OneToOne annotation causes an NPE in hbm2ddl. Removing mappedBy fixes the problem but I can not define the owner of the relationship. The code below causes the NPE. There is no stack trace in the Ant console.
Code:
@Entity(access = AccessType.PROPERTY)
public class TaskConstraint implements Serializable{
    protected TaskSpec taskSpec;

     @OneToOne(mappedBy="taskConstraint")
     public TaskSpec getTaskSpec() {
        return taskSpec;
    }

    public void setTaskSpec(TaskSpec taskSpec) {
        this.taskSpec = taskSpec;
    }

@Entity(access = AccessType.PROPERTY)
public class TaskSpec implements Serializable{
    protected TaskConstraint taskConstraint;
   
    @OneToOne
    @JoinColumn(name="TASK_CONSTRAINT_FK", nullable=false)
    public TaskConstraint getConstraint() {
        return taskConstraint;
    }

    public void setConstraint(TaskConstraint taskConstraint) {
        this.taskConstraint = taskConstraint;
    }
  }


A second problem may be related to the Derby Dialect. At the other end of the relationship, a unique constaint is appllied to the FK in the create table statement. This statement failes as FK is nullable. Adding
Code:
@JoinColumn(name="TASK_CONSTRAINT_FK", nullable=false)

Fixes the problem. However it should not be necessary to define the column name. If a unique contraint is applied, the column should be not null.

Thanks,
Paul


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.