-->
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: hbm2java doesn't get <properties> right.
PostPosted: Tue Jan 16, 2007 10:12 am 
Newbie

Joined: Tue Jan 16, 2007 9:54 am
Posts: 3
I'm trying to create a database and POJO's from my mapping files. Until now, this has worked great. But now I'm trying to assign a unique constraint to 2 columns. I read in the documentation that this can be done using <properties unique="true">. This works great for the schema generation, it does exactly what I want. However, when I let hbm2java generate java code, everything but the values between <properties> get ignored.



This is my mapping file:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
   
<hibernate-mapping>
   <class name="data.FiliaalDag">
      
      <id name="FiliaalDagId" type="long" >
         <generator class="identity"/>
      </id>
      
      <properties name="FiliaalDagUnique" insert="true" update="true" unique="true">
         <property name="datum" type="date" not-null="true">
            <meta attribute="use-in-tostring">true</meta>
         </property>
         
         <many-to-one name="filiaal" class="data.Filiaal" not-null="true">
            <meta attribute="use-in-tostring">true</meta>
         </many-to-one>
      </properties>
      
      <property name="klanten" type="integer" />
      <property name="koopeenheden" type="integer" />               
      
      <set name="persoonlijkeData" cascade="all-delete-orphan" inverse="true">
         <key column="filiaalData" />
         <one-to-many class="data.VerkoperDag" />         
      </set>
            
   </class>
</hibernate-mapping>


This gets generated:
Code:
public class FiliaalDag  implements java.io.Serializable {

    // Fields   

     private Date datum;
     private Filiaal filiaal;

     // Constructors

.... etc.


Without <properties>, this gets generated correctly:
Code:
public class FiliaalDag  implements java.io.Serializable {

    // Fields   

     private long FiliaalDagId;
     private Date datum;
     private Filiaal filiaal;
     private Integer klanten;
     private Integer koopeenheden;
     private Set<VerkoperDag> persoonlijkeData = new HashSet<VerkoperDag>(0);

     // Constructors
... etc


How can I set multi-column unique constraints without confusing hbm2java?

I'm using hbm2java from hibernate tools 3.2.0.beta9


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 16, 2007 12:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
please look in jira if it is not already reported; and otherwise report it as a bug.

_________________
Max
Don't forget to rate


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.