[TENEO] using createSQLQuery [message #612491] |
Tue, 13 November 2007 20:15 |
Will Horn Messages: 265 Registered: July 2009 |
Senior Member |
|
|
I have a teneo annotated ecore model and I have been able to
successfully make HQL queries such as:
session.createQuery("from GeneralCodeItem")
However, if I try to use a SQL query such as:
session.createSQLQuery("select value, description, short_description
from general_code_item").addEntity("GeneralCodeItem")
I get
64606777 [main] INFO org.hibernate.type.StringType - could not read
column value from result set: "VALUE"; Invalid column name
After debugging, I've determined the source of the problem in an
additional set of quotes. The result set has a column VALUE, but
hibernate is looking for "VALUE". When I look in the mapping file, I
see backticks in the column name which I presume is the source of the
extra quotes:
<id name="value" type="java.lang.String">
<column not-null="true" unique="false" name="`VALUE`"/>
</id>
All my column names have backticks. What is the reason for this and is
there anything I can do about it? I have the following workaround, but
it is very verbose and defeats the purpose of having the teneo mappings:
session.createSQLQuery("select {gc}.value {gc.value}, {gc}.description
{gc.description}, {gc}.short_description {gc.shortDescription} from
general_code_item {gc}").addEntity("gc", "GeneralCodeItem")
Thanks!
Will
|
|
|
Powered by
FUDForum. Page generated in 0.02755 seconds