-->
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: Problem in generating database check constraint
PostPosted: Mon Aug 01, 2005 4:35 pm 
Newbie

Joined: Thu Jul 28, 2005 12:23 pm
Posts: 3
Hi,

I am trying to generate a check constraint to a column in adatabase table by using Hibernate. The version of Hibernate I am using is 3.0.

The Hibernate documentation says that to generate a check constraint for a column in a database table, we need to use the check attribute of property tag, that is within the class tag. So in my Hibernate mapping file (the file with [b].hbm.xml[/b] extension), I am specifying the check constraint on my database table column in this manner:
<class name="[b]myClass" table="myTable">
<property name="id" column="REF_CODE" type="java.lang.Integer" check="REF_CODE < 4000" not-null="true" />
</class>[/b]

When I run the org.hibernate.tool.hbm2ddl.SchemaExport utility to generate schema from the configuration file containing an entry to this mapping file, I get the following error on the console:
Error parsing XML: XML InputStream(42) Attribute "check" must be declared for element type "property".

Can you please tell me what I am doing wrong?

Thanks,

Kalpana


Top
 Profile  
 
 Post subject: DTD
PostPosted: Mon Aug 01, 2005 6:30 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Per DTD http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd there is no check attribute on property, it should be used with nested column tag like this:
Code:
<property name="info" >
      <column name="info" check="some check"/>
    </property>
[/code]


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.