Hello,
I am using Hibernate 3.2.4 sp1 and Hibernate Annotations 3.3.0.
I have a single database table that has 2 id's that make up its composite
id. Hence, I would like to create an entity class that maps this table.
The pattern I used was the pattern in the "Java Persistence with Hibernate"
text starting on page 330. First I created an id class. Iam confident
that this id class is correct because this mapping works when I use a
regular old mapping file (*.hbm.xml). The problem comes in when I try
to use the following entity class:
Mapping class
@Entity
@Table(name="database..my_composite_id_table")
@IdClass(MyIds.class)
public class TestComposite
{
@Id
@Column(name="actual_column1")
private Long id1;
@Id
@Column(name="actual_column2")
private Long id2;
//Plus getters and setters
}
Id class (no annotations at all in this class)
public class MyIds
{
private Long id1;
private Long id2;
//Plus getters and setters
//Plus CORRECT implementations of hashcode and equals
}
Iam simply trying to use the patterns in the textbook. Specifically
on page 332.
Now, querying the TestComposite class with
...
Query q = session.createQuery(" from TestComposite t where t.id1 = 123")
...
I get the error:
WARN JDBCExceptionReporter:... "Invalid column name 'id1' ...
Any Ideas?
Thanks
|