-->
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.  [ 2 posts ] 
Author Message
 Post subject: @Check annotation appears to be ignored at property level
PostPosted: Fri Feb 13, 2009 10:20 am 
Newbie

Joined: Fri Feb 13, 2009 9:36 am
Posts: 1
Version 3.4.0
org.hibernate.annotations.Check documentation states:
Quote:
Arbitrary SQL check constraints which can be defined at the class, property or collection level


When used at property level this annotation is not generating the desired constraints in the DDL via hbm2ddl
    @Column(name = "COL_A", length = LENGTH_1)
    @Check(constraints = "COL_A IN ('T','F')")
    public String getColA()
    {
    return this.colA;
    }

    @Column(name = "COL_B", length = LENGTH_1)
    @Check(constraints = "COL_B IN ('Y','N')")
    public String getColB()
    {
    return this.colB;
    }


Is there a way of specifiying constraints for multiple columns at the class level?

I came accross the following bug report which kind of answers my own question:

http://opensource.atlassian.com/projects/hibernate/browse/ANN-587


Top
 Profile  
 
 Post subject: Re: @Check annotation appears to be ignored at property level
PostPosted: Thu Mar 13, 2014 9:32 am 
Newbie

Joined: Thu Mar 13, 2014 9:10 am
Posts: 1
Hey, even your question is 5 years ago is still there. Also the bug is still there. I am using version 4.3.4. But the answer for you is like that:
Code:
@Check(constraints = "gender IN ('MALE','FEMALE') AND occupation IN ('EMPLOYEE','PENSIONER','STUDENT','UNEMPLOYED')")


I just encountered with the same problem. :)

Have fun. :)


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