Hi,
I have the following class attribute declared as a Map with the associated annotations;
@CollectionOfElements
@JoinTable(name="CREDIT_CARD_TRANSACTIONS", joinColumns = @JoinColumn(name="CREDIT_CARD_ID"))
@MapKey(columns=@Column(name="TRAN_ID"))
private Map<String, Transaction> transactions;
I use a String value as the key for the map and the Map value contains a Transaction instance. This all works fine.
I would like to override one of the column names in the CREDIT_CARD_TRANSACTION table so that it is not the default attribute value as so;
@CollectionOfElements
@JoinTable(name="CREDIT_CARD_TRANSACTIONS", joinColumns = @JoinColumn(name="CREDIT_CARD_ID"))
@MapKey(columns=@Column(name="TRAN_ID"))
@AttributeOverride(name="element.description",column=@Column(name="TRAN_DESCRIPTION"))
private Map<String, Transaction> transactions;
However doing so causes an error in which an attempt is made by Hibernate to add the attributes of the String class; value, offset, count, hashCode; into the table as so;
java.sql.SQLException: Table not found in statement [insert into CREDIT_CARD_TRANSACTIONS (CREDIT_CARD_ID, value, offset, count, hashCode, description) values (?, ?, ?, ?, ?, ?)]
The Transaction class is as follows;
@Embeddable
public class Transaction
{
@Column(length=255, nullable=false)
private String description;
...
Why does adding an @AttributeOverride annotation cause this behaviour and is there a way of achieving what I'd like to do using this annotation?
Thank you for your help.
|