-->
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: Bad SQL grammar for DML update w/ CompositeUserType
PostPosted: Fri Mar 31, 2006 10:37 pm 
Newbie

Joined: Tue Nov 09, 2004 4:03 pm
Posts: 1
Hibernate version: 3.1.1
Name and version of the database you are using: Postgres 8

I have several multi-column value objects, like Money:

Code:
public class Money implements Comparable, Serializable {
    private final BigDecimal amount;
    private final Currency currency;

    public Money(BigDecimal amount, Currency currency) {
        ...
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public Currency getCurrency() {
        return currency;
    }

    ...
}


These objects are used as properties on entities and are mapped as such:

Code:
...
public class SomeEntity {
    ...

    private Money money;

    @Columns(columns = { @Column(name = "money_amount"), @Column(name = "money_currency" })
    @Type("money")
    public Money getMoney() { return money; }

    public void setMoney(Money money) { this.money = money; }

    ...
}


Each value object has a CompositeUserType, and everything works fine for all other cases. However, when I try to DML update an entity with a Money property (or any other value object mapped to more than one column), I get bad SQL grammar:

Code:
could not execute update query; bad SQL grammar [update some_entity set money_amount, money_currency1=null where other_prop=?]; nested exception is java.sql.SQLException: ERROR: syntax error at or near ","


So, it looks like the thing that's mapping the property name to the column name(s) doesn't take proper SQL update syntax into account. I haven't been able to find anything in JIRA about this, nor did I see it in the changelog for 3.1.2 or 3.1.3. Is this a bug (that I should file), or am I missing something?

Thanks


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.