-->
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.  [ 1 post ] 
Author Message
 Post subject: hbm2java issues when specifying composite-id in mapping
PostPosted: Thu Sep 15, 2011 2:53 pm 
Newbie

Joined: Wed Sep 14, 2011 8:55 am
Posts: 2
The following hibernate-mapping file fails to produce (a) the specified composite-id class "MatrixCsvCPK" and (b) does not include the "csv" attribute (and its getter/setter methods) in the generated class file "MatrixCsvBase".

Code:
<hibernate-mapping package="com.riskcontrollimited.stresscontroller.data">
   
    <class name="com.riskcontrollimited.stresscontroller.data.MatrixCsv" table="sc_matrix_csv">
       
        <meta attribute="class-description">Base-class for SC_MATRIX_CSV records, generated by Hibernate-Tools.</meta>
        <meta attribute="extends">com.riskcontrollimited.stresscontroller.data.DataObject</meta>
        <meta attribute="generated-class">com.riskcontrollimited.stresscontroller.data.MatrixCsvBase</meta>
       
        <composite-id name="compositId" class="com.riskcontrollimited.stresscontroller.data.MatrixCsvCPK">
            <meta attribute="scope-field">protected</meta>
            <key-many-to-one name="estimationId"    class="Estimation"    column="estimation_id"/>
            <key-many-to-one name="accountGroupId"  class="AccountGroup"  column="account_group_id"/>
            <key-property    name="dataVersionId"   type="long"           column="data_version_id"/>
            <key-many-to-one name="matrixTypeId"    class="MatrixType"    column="matrix_type_id"/>
            <key-many-to-one name="variableId"      class="Variable"      column="variable_id"/>
        </composite-id>
       
        <property name="csv" type="text">
            <meta attribute="scope-field">protected</meta>
            <column name="csv" not-null="true"/>
        </property>
       
    </class>
   
</hibernate-mapping>


I have hit the buffers with this issue: I cannot get the hbm2java tool to generate a class that includes the "csv", nor can I get it to produce the (additional) composite-id class that is also required at runtime.

Here is the "MatrixCsvBase" class that is being produce - notice, no "csv" attribute:

Code:
public class MatrixCsvBase extends com.riskcontrollimited.stresscontroller.data.DataObject implements java.io.Serializable {

    protected Estimation estimationId;
    protected AccountGroup accountGroupId;
    protected long dataVersionId;
    protected MatrixType matrixTypeId;
    protected Variable variableId;

    public MatrixCsvBase() { }

    public MatrixCsvBase( Estimation estimationId, AccountGroup accountGroupId, long dataVersionId, MatrixType matrixTypeId, Variable variableId ) {
       this.estimationId = estimationId;
       this.accountGroupId = accountGroupId;
       this.dataVersionId = dataVersionId;
       this.matrixTypeId = matrixTypeId;
       this.variableId = variableId;
    }
   
    public Estimation getEstimationId() {
        return this.estimationId;
    }
   
    public void setEstimationId(Estimation estimationId) {
        this.estimationId = estimationId;
    }
   
    public AccountGroup getAccountGroupId() {
        return this.accountGroupId;
    }
   
    public void setAccountGroupId(AccountGroup accountGroupId) {
        this.accountGroupId = accountGroupId;
    }
   
    public long getDataVersionId() {
        return this.dataVersionId;
    }
   
    public void setDataVersionId(long dataVersionId) {
        this.dataVersionId = dataVersionId;
    }
   
    public MatrixType getMatrixTypeId() {
        return this.matrixTypeId;
    }
   
    public void setMatrixTypeId(MatrixType matrixTypeId) {
        this.matrixTypeId = matrixTypeId;
    }
   
    public Variable getVariableId() {
        return this.variableId;
    }
   
    public void setVariableId(Variable variableId) {
        this.variableId = variableId;
    }

}


I am calling the hbm2java tool via Ant. (The tool otherwise appears to work successfully: I have several other mapping files - without composite IDs - and all the classes are generated as expected.)

I am using Hibernate tools version 3.3.2.GA and Hibernate version 3.2.7.ga.

Can anyone shine any light on this issue, please?

Is there a bug, or am I missing something?

Harry Mantheakis
London, UK


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.