-->
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.  [ 8 posts ] 
Author Message
 Post subject: cannot find getter for elements of form aAAAaaaa...
PostPosted: Thu May 19, 2005 11:44 am 
Newbie

Joined: Fri Apr 08, 2005 2:22 pm
Posts: 8
Hibernate throws an acception claiming that it can't find the getter for any member where the first letter is lower case and the second letter is upper case. The code below is considering a property with the name sICCode__c, though if I change that element to siCCode__c then the same error is thrown on a different element later in the hibernate file.

Is this a known error? Is there a work around? Changing each of these elements to start with two lower case letters does fix this problem, but I run into problems in other parts of the program if I do this, so it isn't a pracial solution.

Any ideas?

If you need more code than is present below, please let me know and I would be more than happy to provide it.

Hibernate version:
Hibernate version 3.0

Mapping documents:
<class name="com.ci.db.member.LeadBean" table="lead_sf" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false" batch-size="1" select-before-update="false" optimistic-lock="version">
<id name="id" type="int" unsaved-value="null">
<column name="row_id" sql-type="int" not-null="true" />
<generator class="identity" />
</id>
...
<property name="rating" type="java.lang.String">
<column name="rating" sql-type="varchar(100)" not-null="false" />
</property>
<property name="sICCode__c" type="java.lang.String">
<column name="sICCode__c" sql-type="varchar(100)" not-null="false" />
</property>

<property name="salutation" type="java.lang.String">
<column name="salutation" sql-type="varchar(100)" not-null="false" />
</property>
<property name="state" type="java.lang.String">
<column name="state" sql-type="varchar(100)" not-null="false" />
</property>
...
</class>

Code from LeadBean.java
package com.ci.db.member;

import java.io.Serializable;
import com.sforce.soap.partner.ID;
import java.util.Calendar;
import java.util.Date;
import org.apache.commons.lang.builder.ToStringBuilder;


/** @author Hibernate CodeGenerator */
public class LeadBean extends BusinessObject implements Serializable {

...

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

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

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

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

...

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

...

public String getRating() {
return this.rating;
}

public void setRating(String rating) {
this.rating = rating;
}

public String getSICCode__c() {
return this.sICCode__c;
}

public void setSICCode__c(String sICCode__c) {
this.sICCode__c = sICCode__c;
}

public String getSalutation() {
return this.salutation;
}

public void setSalutation(String salutation) {
this.salutation = salutation;
}

public String getState() {
return this.state;
}

public void setState(String state) {
this.state = state;
}

...

}


Code where error occurs:
sf = new Configuration().configure(sessionIdentifier).buildSessionFactory();

Full stack trace of any exception that occurs:
org.hibernate.PropertyNotFoundException: Could not find a getter for sICCode__c in class com.ci.db.member.LeadBean

at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java)

at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:207)

at org.hibernate.mapping.Property.getGetter(Property.java)

at org.hibernate.tuple.PojoTuplizer.buildPropertyGetter(PojoTuplizer.java)

at org.hibernate.tuple.AbstractTuplizer.<init>(AbstractTuplizer.java:73)

at org.hibernate.tuple.PojoTuplizer.<init>(PojoTuplizer.java:54)

at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:47)

at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:212)

at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400)

at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104)

at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)

at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)

at com.ci.db.HibernateGenericUtil.currentSession(HibernateGenericUtil.java:71)

at com.ci.sync.utility.Utility.getCRMConnection(Utility.java:130)

at com.ci.sync.SyncController.main(SyncController.java:59)


Name and version of the database you are using:
MySQL 3.0.10


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 1:38 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Hi rhuber,

use this getter and setter method:

Code:
public String get[color=red]s[/color]ICCode__c() {
   return this.sICCode__c;
}

public void set[color=red]s[/color]ICCode__c(String sICCode__c) {
   this.sICCode__c = sICCode__c;
}


You have to write it this way, if the first letter of your propery is lowercase and the following one uppercase.

Best regards
Sven


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 1:40 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
sven wrote:
Hi rhuber,

use this getter and setter method:

Code:
public String get[color=red]s[/color]ICCode__c() {
   return this.sICCode__c;
}

public void set[color=red]s[/color]ICCode__c(String sICCode__c) {
   this.sICCode__c = sICCode__c;
}


You have to write it this way, if the first letter of your propery is lowercase and the following one uppercase.

Best regards
Sven


Of course, you have to leave out the BBCode. Don't know why it didn't get red there...


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 1:56 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
sven wrote:
Of course, you have to leave out the BBCode. Don't know why it didn't get red there...


None of the formating works inside the [code] tags.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 1:57 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
You're right. My fault...


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 2:48 pm 
Newbie

Joined: Fri Apr 08, 2005 2:22 pm
Posts: 8
Thank you very much sven, that did the trick.

Is this a java quirk that I have never noticed before or is this an issue within hibernate itself?

FieldProperty.getAccessorName() in hibernate-tools 2.0 does not produce accessornames according to this rule and in the case of a field name SICCode gives an accessor name of sICCode.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 2:59 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
As far as I know, it is a Java guideline to write it this way and not Hibernate specific resp. CGLIB specific.
My Java IDE also writes it this way when creating the accessor methods automatically.

Code:
private String abcdef; // usual case
private String ABCDEF; // special case
private String aBCDEF; // special case

public String getAbcdef() {
   return abcdef;
}

public String getABCDEF() {
   return ABCDEF;
}

public String getaBCDEF() {
   return aBCDEF;
}


Unfortunately, I don't have an official resource which deals with this topic.
Though I hope it helps.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 11, 2008 5:54 am 
Newbie

Joined: Tue Nov 11, 2008 5:27 am
Posts: 1
There is still one issue with the way hibernate looks up the methods
for a given property name.

Suppose you have a property with a name like "xCoord" (first
lowercase, second uppercase, rest doesn't matter). Not the accessor
methods in the source code will be getXCoord and setXCoord.

The way BasicPropertyAccessor.getterMethod is implemented however
this method is not found. The reason is the special case for
decapitalizing accessor names. So getXCoord will become XCoord
and will stay XCoord after decapitalizing. This doesn't match the
property name. So this direction (accessor method name ->
property name) looses information. Better is the other direction
(property name -> accessor method name) with a final method lookup.

BasicPropertyAccessor.getterMethod should be changed.


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