-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: @any mapping : update bug with malformed query ?
PostPosted: Fri Jul 01, 2011 9:47 am 
Newbie

Joined: Mon Jun 27, 2011 12:39 pm
Posts: 3
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)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.