> -----Original Message-----
> From: racarlson [mailto:[email protected]]
> Sent: Monday, January 11, 2010 9:00 AM
> To: [email protected]
> Subject: openjpa ignoring column annotation
> 
> 
> I have the following annotation and variable name (getter/setter)
> listed
> below, if I change it to add an underscore it works, but with the
> column
> name different than the getter/setter it gives me an errors. Hibernate
> jpa
> didn't do this. I also listed the error below, how do I get this to
> work
> with openjpa, using a different column name than variable, our project
> is
> large and we can't go through changing all the column names right now,
> we
> are trying to use openjpa instead of hibernate since its built into
the
> j2ee
> container

I assume by "if I change it to add an underscore", you're referring to
the property name inferred by the getter method name, and not the column
name?

Assuming that's true, I'd say that tells us that your @Column annotation
is being completely ignored, as adding an underscore to the property
name would result in the default mapping to the column name.

It's possible that you're using both FIELD and PROPERTY access, which
won't work.  Personally, I only use FIELD access.

It's curious that the error message says "does not have any public
fields or setter methods".  FIELD access doesn't require the field to be
public.  It also specifically refers to "setter" methods, which seems to
imply the annotation should be on the setter, not the getter.

>     private java.sql.Timestamp dateCreated;
> 
>     @Column(name = "DATE_CREATED")
>     public java.sql.Timestamp getDateCreated()
>     {
>         return this.dateCreated;
>     }
> 
>     public void setDateCreated(java.sql.Timestamp dateCreated)
>     {
>         this.dateCreated = dateCreated;
>     }
> 
> the error:
> <1.0.0 nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: Result type "class
> Account" does not have any public fields or setter methods for the
> projection or aggregate result element "DATE_CREATED", nor does it
have
> a
> generic put(Object,Object) method that can be used, nor does it have a
> public constructor that takes the types null.

Reply via email to