-->
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.  [ 7 posts ] 
Author Message
 Post subject: BasicPropertyAccessor
PostPosted: Wed Jan 14, 2004 11:29 am 
Newbie

Joined: Tue Nov 11, 2003 8:22 am
Posts: 5
In class net.sf.hibernate.property.BasicPropertyAccessor

the private static Method setterMethod/getterMethod use java.bean
Introspector.decapitalize method to decapitalize the setter/getter emthod of the beans, however, in certain situation the getter and setter method may have like getSLxx or setSLxx then this Introspector.decapitalize api will give SLxx propertyname which cause error "unable to find getter or setter method" since it would expect the field like sLxx in the java class.

I found this behavior since our Oracle DBA defined the name as S_Lxx in
the table schema and I applied middlegen to automatically generate the xml mapping files from Oracle database and run codegenerator to create java class and encountered this kind of unexpected behavior in running the application. The middlegen will drop out underscore and write the field variable sLxx then the errors come out.

I bypassed this problem just simply using String api to lower the case of first character of the string. I am not sure whether it is good in general but works in our case.

Sincerely,

Jun-Liang


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 14, 2004 11:38 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
http://www.hibernate.org/116.html#A30

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 14, 2004 11:39 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Sorry, can you post it to middlegen JIRA, please

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 4:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Can you give a very small example. Include it in the report. You could put this into Hibernates JIRA or send it directly to me (david@hibernate.org).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 10:37 am 
Newbie

Joined: Tue Nov 11, 2003 8:22 am
Posts: 5
here is the example xml mapping file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.transtech.bean.Sysgroup" table="SYSGROUP" schema="T4DBA">
<id name="lSerialno" column="L_SERIALNO" type="long">
<generator class="native"/>
</id>
<property name="sOpgroupid" column="S_OPGROUPID" type="string" length="15" not-null="true"/>
<property name="sOpgroupname" column="S_OPGROUPNAME" type="string" length="50" not-null="true"/>
<property name="sOpdescribe" column="S_OPDESCRIBE" type="string" length="255"/>
<property name="dtCreate" column="DT_CREATE" type="timestamp" length="7"/>
<property name="dtUpdate" column="DT_UPDATE" type="timestamp" length="7"/>
<property name="sIdno" column="S_IDNO" type="string" length="15"/>
</class>
</hibernate-mapping>

and the java code generated from class net.sf.hibernate.tool.hbm2java.CodeGenerator

import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/** @author Hibernate CodeGenerator */
public class Sysgroup implements Serializable {

/** identifier field */
private Long lSerialno;

/** persistent field */
private String sOpgroupid;

/** persistent field */
private String sOpgroupname;

/** nullable persistent field */
private String sOpdescribe;

/** nullable persistent field */
private java.util.Date dtCreate;

/** nullable persistent field */
private java.util.Date dtUpdate;

/** nullable persistent field */
private String sIdno;

/** full constructor */
public Sysgroup(java.lang.String sOpgroupid, java.lang.String sOpgroupname, java.lang.String sOpdescribe, java.util.Date dtCreate, java.util.Date dtUpdate, java.lang.String sIdno) {
this.sOpgroupid = sOpgroupid;
this.sOpgroupname = sOpgroupname;
this.sOpdescribe = sOpdescribe;
this.dtCreate = dtCreate;
this.dtUpdate = dtUpdate;
this.sIdno = sIdno;
}

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

/** minimal constructor */
public Sysgroup(java.lang.String sOpgroupid, java.lang.String sOpgroupname) {
this.sOpgroupid = sOpgroupid;
this.sOpgroupname = sOpgroupname;
}

public java.lang.Long getLSerialno() {
return this.lSerialno;
}

public void setLSerialno(java.lang.Long lSerialno) {
this.lSerialno = lSerialno;
}

public java.lang.String getSOpgroupid() {
return this.sOpgroupid;
}

public void setSOpgroupid(java.lang.String sOpgroupid) {
this.sOpgroupid = sOpgroupid;
}

public java.lang.String getSOpgroupname() {
return this.sOpgroupname;
}

public void setSOpgroupname(java.lang.String sOpgroupname) {
this.sOpgroupname = sOpgroupname;
}

public java.lang.String getSOpdescribe() {
return this.sOpdescribe;
}

public void setSOpdescribe(java.lang.String sOpdescribe) {
this.sOpdescribe = sOpdescribe;
}

public java.util.Date getDtCreate() {
return this.dtCreate;
}

public void setDtCreate(java.util.Date dtCreate) {
this.dtCreate = dtCreate;
}

public java.util.Date getDtUpdate() {
return this.dtUpdate;
}

public void setDtUpdate(java.util.Date dtUpdate) {
this.dtUpdate = dtUpdate;
}

public java.lang.String getSIdno() {
return this.sIdno;
}

public void setSIdno(java.lang.String sIdno) {
this.sIdno = sIdno;
}

public String toString() {
return new ToStringBuilder(this)
.append("lSerialno", getLSerialno())
.toString();
}

public boolean equals(Object other) {
if ( !(other instanceof Sysgroup) ) return false;
Sysgroup castOther = (Sysgroup) other;
return new EqualsBuilder()
.append(this.getLSerialno(), castOther.getLSerialno())
.isEquals();
}

public int hashCode() {
return new HashCodeBuilder()
.append(getLSerialno())
.toHashCode();
}

}


Since we have more than hundred tables in Oracle DB so I would like to use tools to generate automatically xml mapping files and java codes otherwise it would be very painful to re-examine the codes one by one.

Thanks for the help!

Regards,

Jun-Liang


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 7:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Thanks - Ill have a look to see what I can do.


Top
 Profile  
 
 Post subject: The fix that we found
PostPosted: Wed Jun 23, 2004 11:37 am 
Newbie

Joined: Thu May 27, 2004 9:14 am
Posts: 11
We are having the same problem with fields that are like a_foo and we use middlegen/hibernate hbm2java.

The problem is that middlegen creates the attribute improperly as Emanuel mentioned.

We were able to fix this by modifying the prefs file that middlegen creates the first time it creates the hbm files.

The first time around the the prefs file will create the attribute as aFoo according to the FAQ that emanual pointed out. Now modify the prefs file at the root of your source tree and find that attribute and rename it to AFoo. Every time you do a regen now use middlegen it will work correctly.

Best of luck,

Cory


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