Having a class like:
{code} @Entity @Table(name="CONTRACT", schema="MYSCHEMA") public class Contract { @Id @ColumnTransformer(read="BINARY(CONTRACT_KEY)") @Column(name="CONTRACT_KEY", updatable=false) private byte[] contractKey; [...] } {code}
1.) Using this code to retrieve an object: {code} byte[] key = new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; Contract contract = em.find(Contract.class, key); {code} results in this SQL statement:
{noformat} select businessco0_.BUSI_CONT_MAIN_KEY as BUSI_CON1_0_0_ from MYSCHEMA.CONTRACT businessco0_ where businessco0_.CONTRACT_KEY=? {noformat}
The @ColumnTransformer is neither applied on the select field nor on the where clause.
2.) Using this code to retrieve an object: {code} byte[] key = new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; TypedQuery<Contract> query = em.createQuery("select c from Contract c where c.contractKey = ?1", Contract.class); query.setParameter(1, key); Contract contract = query.getSingleResult(); {code} results in this SQL statement:
{noformat} select businessco0_.CONTRACT_KEY as BUSI_CON1_0_, BINARY(businessco0_.OTHER_KEY) as OTHER_KEY27_0_ from MYSCHEMA.CONTRACT businessco0_ where BINARY(businessco0_.CONTRACT_KEY)=? {noformat}
Now the @ColumnTransformer is correctly applied on the where clause, but not on the selection. Other non @Id fields which also have an @ColumnTransformer annotation are correctly created in above SQL statement (in above example column OTHER_KEY).
Bug or feature?
|