-->
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.  [ 6 posts ] 
Author Message
 Post subject: @NonNull does not do "not null" for @Id composite-
PostPosted: Mon Nov 06, 2006 11:22 am 
Regular
Regular

Joined: Thu Oct 13, 2005 4:19 am
Posts: 98
For a composite-id of a legacy database I took the "annotate the component property as @Id and make the component class @Embeddable" approach.
However MS SQLServer complaints:
Code:
Unsuccessful: create table Dog(house int null, person int null, primary key (house, person))
Cannot define PRIMARY KEY constraint on nullable column in table


It's clear the create table should contain "house int not null", because my code has a @NotNull.

Here's the code:
Code:
@Embeddable
public class DogId implements Serializable {

    private House house;
    private Person person;

    @ManyToOne(fetch = FetchType.EAGER)
    @NotNull
    @JoinColumn(name = "house")
    public House getHouse() {
        return house;
    }
    ...
}


Code:
@Entity
public class Dog extends ComparablePersistable {

    DogId id;

    @Id
    @NotNull
    public DogId getId() {
        return id;
    }

    public void setId(DogId id) {
        this.id = id;
    }
    ...
}


I am using 3.2.0.ga. Is there a JIRA for this?[/b][/code]

_________________
http://www.ohloh.net/accounts/ge0ffrey


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 8:12 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
check the unit test suite org.hibernate.test.annotations.cid
There is an example where the not null is generated.

If you can alter the testcase and make it fail, submit it to JIRA

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 10:45 am 
Regular
Regular

Joined: Thu Oct 13, 2005 4:19 am
Posts: 98
k, I 'll see if I can get hibernate3's trunk booted :)

I made some testcase patches for jboss rules lately (and those issues got fixed very fast due to those testcase patches), but because they use maven2, I got that booted very fast with a "mvn install idea:idea"...

_________________
http://www.ohloh.net/accounts/ge0ffrey


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 10:47 am 
Regular
Regular

Joined: Thu Oct 13, 2005 4:19 am
Posts: 98
PS: the workaround is adding this:
@JoinColumn(nullable = false)

_________________
http://www.ohloh.net/accounts/ge0ffrey


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 6:46 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
ge0ffrey wrote:
"mvn install idea:idea"...


I kinda think something is wrong when a build system ask you to type the task name twice ;-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 4:46 am 
Regular
Regular

Joined: Thu Oct 13, 2005 4:19 am
Posts: 98
It's a maven2 thing :)
Essentially you ask
- do the install phase
- do of the plugin idea the goal idea

You can also do "mvn idea:clean eclipse:clean", which cleans the *.ipr and .project/.classpath files.

_________________
http://www.ohloh.net/accounts/ge0ffrey


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