3

The following error message appears

java.lang.IllegalArgumentException: 
The attribute [eMailStatus] 
from the managed type [EntityTypeImpl@902966747:PersonJpaDao 
   [ javaType: class com.bitplan.smartCRM.jpa.PersonJpaDao descriptor: 
   RelationalDescriptor(com.bitplan.smartCRM.jpa.PersonJpaDao --> [DatabaseTable(Person)]),  
   mappings: 46]] 
is not present.
    at 
 org.eclipse.persistence.internal.jpa.metamodel.ManagedTypeImpl.getAttribute(ManagedTypeImpl.java:147)

while the annotation and getters and setters are present:

 /**
   * getter for xsd:string/String EMailStatus
   * @return eMailStatus
   */
  @Column(name="eMailStatus")
  public String getEMailStatus() { 
    return getPersonImpl().getEMailStatus(); 
  }

  /**
   * setter for xsd:string/String EMailStatus
   * @param peMailStatus - new value for EMailStatus
   */
  public void setEMailStatus(String peMailStatus) { 
    getPersonImpl().setEMailStatus(peMailStatus); 
  }

My assumption is that the naming of the field is relevant: if the first letter of the field is lowerCase and the second is uppercase than the problem seems to show. Propertynames like:

  • SSN
  • EMailStatus

are o.k but e.g.

  • eMailStatus
  • xStatus

are not.

What could be going on here and how could I debug this to find out how to fix this?

I am guessing that the JavaBean spec capitalization rules are the culprit here as outlined in a comment of Where is the JavaBean property naming convention defined?

Community
  • 1
  • 1
Wolfgang Fahl
  • 12,097
  • 9
  • 75
  • 150

1 Answers1

4

The Criteria query snippet:

Path<String> beanValue = qh.from.<String> get(beanField);

Has to be done with EMailStatus not eMailStatus as the beanField content - even if the propertie's name is eMailStatus and only the getter has an upperCase "E" due to java beans conventions. I have not found out why yet - so other answers are still appreciated.

The Introspector decapitalize function is what might be helpful here.

it also works to rename the column to "EMailStatus":

  /**
   * getter for xsd:string/String EMailStatus
   * @return eMailStatus
   */
  @Column(name="EMailStatus")
  public String getEMailStatus() { 
    return getPersonImpl().getEMailStatus(); 
  }

  /**
   * setter for xsd:string/String EMailStatus
   * @param peMailStatus - new value for EMailStatus
   */
  public void setEMailStatus(String peMailStatus) { 
    getPersonImpl().setEMailStatus(peMailStatus); 
  }
Wolfgang Fahl
  • 12,097
  • 9
  • 75
  • 150
  • I have something like cq.where(cb.like(cb.lower(root. get(propertyName)), value)); that ignores the case converting it to lower case but still it works only when the exact case sensitivity is maintained as per the field declared in the calss. – Kaizar Laxmidhar Oct 01 '15 at 14:42