Hello,
I've got a double mapping using the @Any annotation, as following :
Code:
class ItemContainer {
...
@Any(metaColumn = @Column(name = "TYPE"), fetch = FetchType.LAZY)
@AnyMetaDef(idType = "long", metaType = "string", metaValues = { @MetaValue(targetEntity = CClass.class, value = "C"), @MetaValue(targetEntity = TClass.class, value = "T") })
@JoinColumn(name = "TYPE_ID")
private IItem item;
@Any(metaColumn = @Column(name = "TYPE_SAVED"), fetch = FetchType.LAZY)
@AnyMetaDef(idType = "long", metaType = "string", metaValues = { @MetaValue(targetEntity = SClass.class, value = "S") })
@JoinColumn(name = TYPE_SAVED_ID)
private ISavedItem savedItem;
}
I'm trying to execute and update on this class : I want to update the reference to my ISavedItem given a specific IITem.
I'm using the following request :
Quote:
update ItemContainer ic set ic.savedItem=:item where ic.item.id=:itemId and ci.item.class=:itemClazz
and passing as parameters :
Quote:
query.setParameter("itemId", 8)
.setParameter("itemClazz", CClass.class.getCanonicalName())
.setParameter("savedItem", mySavedItem)
However, the request executed is the following, with a syntax error :
Code:
update
CART_ITEM
set
TYPE_SAVED,
TYPE_SAVED_ID=(?,
?)
where
and TYPE_ID=?
and TYPE=?
[01/07/2011 15:27:45] [TRACE] org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [1] as [BIGINT] - 26
[01/07/2011 15:27:45] [TRACE] org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [2] as [VARCHAR] - <null>
[01/07/2011 15:27:45] [TRACE] org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [3] as [VARCHAR] - <null>
[01/07/2011 15:27:45] [TRACE] org.hibernate.type.descriptor.sql.BasicBinder - binding parameter [4] as [BIGINT] - 8
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' TYPE_SAVED_ID=('C', 31) where CART_ID=27 and TYPE_ID=12727 and TYPE='T'' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
Is this a known bug, an error in my script, or should I open a ticket ?
PS :
This works:
Quote:
query.setParameter("itemId", 8)
.setParameter("itemClazz", CClass.class.getCanonicalName())
.setParameter("savedItemClazz", SClass.class.getCanonicalName())
.setParameter("savedItemId", 26)