I'm almost positive that this is a mapping/annotation problem, but I'm at a total loss as to how to fix it. I have a few hundred columns mapped properly. 2 are not working. Those two had the same name, but now I've renamed one of them and it still has the same problem, so the naming similarity is just a coincidence.
table_a has a field with the following signature (notice two 'n's misspelling) (BROKEN):
Code:
`num_anncestors` int(11) NOT NULL
For reference, table_c has the following column which WORKS:
Code:
`password_life_days` int(11) NOT NULL
Yesterday, when I used Hibernate .hbm.xml files this wasn't a problem. I just converted to JPA annotations and everything else seems to be working, even the other columns of these same tables. Just reading this one column has no effect and referencing it in a criteria query produces: "org.hibernate.QueryException: could not resolve property: numAnncestors of: TableA". I haven't updated anything to use the JPA EntityManager instead of Hibernate.Session.
Here are the (new) mappings BROKEN:
Code:
@javax.persistence.Entity
@Table(name="table_a"
,catalog="mydb"
)
public class TableA implements java.io.Serializable {
...
@Column(name="num_anncestors", nullable=false)
@Override
public int numAnncestors() { return numAnncestors; }
public void setNumAnncestors(int x) { numAnncestors = x; }
...
TableC WORKS:
Code:
@javax.persistence.Entity
@Table(name="table_c"
,catalog="mydb"
, uniqueConstraints = @UniqueConstraint(columnNames="identifier_c")
)
public class TableC implements java.io.Serializable {
...
@Column(name="password_life_days", nullable=false)
public int getPasswordLifeDays() { return passwordLifeDays; }
public void setPasswordLifeDays(int x) { passwordLifeDays = x; }
...
When I try to do a criteria query, I get an exception:
Code:
// This used to work, but now I get:
// org.hibernate.QueryException: could not resolve property: numAnncestors of: TableA
crit.add(Restrictions.eq("numAnncestors", 0),
// This doesn't work either:
// org.hibernate.QueryException: could not resolve property: TableA of: TableA
crit.add(Restrictions.eq("TableA.numAnncestors", 0),
// This doesn't work either:
// org.hibernate.QueryException: could not resolve property: TableA of: TableA
crit.createAlias("TableA", "a");
crit.add(Restrictions.eq("a.numAnncestors", 0),
I just set up my "datasource" in IDEA 12 and the inspections are not showing any warnings or issues. If I map a column wrong, they show an error. When I correct it, the error goes away. I feel out of ideas, which is unusual for me.
I had originally suspected that having a column with the same name in another table was causing an issue, but I have renamed the column so that's not the case any more (misspelled anNcestors).
Database is MySQL 5.1
Java7
Hibernate 3.6.10
Ubuntu 12.04 64-bit