-->
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.  [ 5 posts ] 
Author Message
 Post subject: hbm2java generates correct sql but wrong java file
PostPosted: Sun Feb 05, 2006 3:39 am 
Newbie

Joined: Sun Jan 29, 2006 7:45 pm
Posts: 5
The table generated has all these columns, but java file has only columns from "component" tag. The first four members are missing. In general, when I deal with "component" or for that matter other classes that are being referred, do I need to specify any additional info?

Table looks fine
===========

PROFILE_ID
PROFILE_DISPLAY_NAME
PROFILE_EMAIL
PROFILE_BIRTHDATE
initial
first
last

Mapping file
=======

<class name="com.automationschool.core.Profile" table="PROFILE">
<meta attribute="class-description">
Profile of a person (Student, Teacher, etc.)

@author Kumar Ramaiyer
</meta>
<meta attribute="generated-class">com.automationschool.core.ProfileBase</meta>
<!-- <meta attribute="implement-equals">true</meta>
<meta attribute="implement-hashcode">true</meta>
<meta attribute="scope-field">protected</meta> -->

<id name="id" type="string" unsaved-value="null" >
<column name="PROFILE_ID" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>
<property column="PROFILE_DISPLAY_NAME" name="displayName" type="string">
<meta attribute="field-description">
The display name of the person.
</meta>
</property>
<property column="PROFILE_EMAIL" name="email" type="string">
<meta attribute="field-description">
The email of the person.
</meta>
</property>
<property column="PROFILE_BIRTHDATE" name="birthday" type="date">
<meta attribute="field-description">
The birthdate of the person.
</meta>
</property>
<component name="Name" class="com.automationschool.core.Name">
<property name="initial" type="string"/>
<property name="first" type="string"/>
<property name="last" type="string"/>
</component>
</class>


Generated Java
==========

package com.automationschool.core;

// Generated Feb 4, 2006 11:19:00 PM by Hibernate Tools 3.1.0.beta4

/**
* Profile of a person (Student, Teacher, etc.)
*
* @author Kumar Ramaiyer
*
*/

public class ProfileBase implements java.io.Serializable {

// Fields

private String initial;

private String first;

private String last;

// Constructors

/** default constructor */
public ProfileBase() {
}

/** full constructor */
public ProfileBase(String initial, String first, String last) {
this.initial = initial;
this.first = first;
this.last = last;
}

// Property accessors

public String getInitial() {
return this.initial;
}

public void setInitial(String initial) {
this.initial = initial;
}

public String getFirst() {
return this.first;
}

public void setFirst(String first) {
this.first = first;
}

public String getLast() {
return this.last;
}

public void setLast(String last) {
this.last = last;
}

}


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 05, 2006 4:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
please report this in jira

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 05, 2006 9:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
..and then don't ;)

just tested this and the problem is that you have this:

<meta attribute="generated-class">
com.automationschool.core.ProfileBase
</meta>

and meta attributes inherits by default, meaning the component will get it too.

use this instead:
<meta attribute="generated-class" inherit="false">
com.automationschool.core.ProfileBase
</meta>

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 05, 2006 12:18 pm 
Newbie

Joined: Sun Jan 29, 2006 7:45 pm
Posts: 5
thanks a lot. That worked.

I see now. Because it inherits, it quietly generates file with the same name for the component, overriding.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 05, 2006 12:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, i should probably error or warn on that situation.

_________________
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.  [ 5 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.