-->
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.  [ 4 posts ] 
Author Message
 Post subject: NotNull propagated to sibling classes in hierarchy !!!
PostPosted: Sat Sep 12, 2009 3:47 pm 
Newbie

Joined: Sat Jan 03, 2009 6:33 pm
Posts: 11
Hi,
I'm using validator-3.1, core-3.3.1, annotations-3.4.
Here is my problem, may be a bug:

Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Parent
{
    @Id
    int id;

    @Column(nullable = true)
    String string;

    public int getId() { return this.id; }
    public String getString() { return this.string; }
}

@Entity
public class CanBeNull
    extends Parent
{
}

@Entity
public class CannotBeNull
    extends Parent
{
    // omitted for demo: @Column(nullable = false)
    @NotNull
    @Override
    public String getString() { return this.string; }
}


Now the DDL looks like:

Code:
CREATE TABLE cannot_be_nulls
(
  id integer NOT NULL,
  string character varying(255) NOT NULL,
  CONSTRAINT cannot_be_nulls_pkey PRIMARY KEY (id)
)
CREATE TABLE can_be_nulls
(
  id integer NOT NULL,
  string character varying(255) *************NOT NULL*******************,
  CONSTRAINT can_be_nulls_pkey PRIMARY KEY (id)
)


This does not happen if I use @MappedSuperclass on Parent, but I need @Entity because some other entity have references to Parent.
This is quite annoying... Is there something i can do, is this a bug (looks like), should i open an issue on jira ?
Thanks

David


Top
 Profile  
 
 Post subject: Re: NotNull propagated to sibling classes in hierarchy !!!
PostPosted: Sun Sep 13, 2009 6:40 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

seems to be a bug. The DDL is also correct when @MappedSuperclass is used or when CannotBeNull is not mapped at all.
However, I think this is really a Hibernate Tools bug. Hibernate Annotations and Validator provide the meta data, but Hibernate
Tools generates the actual DDL. You might want to post your question there or check Jira for Hibernate Tools.

--Hardy


Top
 Profile  
 
 Post subject: Re: NotNull propagated to sibling classes in hierarchy !!!
PostPosted: Sun Sep 13, 2009 9:02 am 
Newbie

Joined: Sat Jan 03, 2009 6:33 pm
Posts: 11
Thanks
I posted this question to the tools forum: https://forum.hibernate.org/viewtopic.php?f=6&t=999597&start=0.
I will update this thread if I fill a jira.


Top
 Profile  
 
 Post subject: Re: NotNull propagated to sibling classes in hierarchy !!!
PostPosted: Thu Sep 24, 2009 3:38 pm 
Newbie

Joined: Sat Jan 03, 2009 6:33 pm
Posts: 11
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4461


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