Hi,
I have situation where in hiberate/jpa combination works fine without using spring. Exact same select query is fired but when used with spring it cannot find the column (using alias) but works fine without spring. Here is query:
select author0_.au_id as au1_0_4_, author0_.address as address0_4_, author0_.city as city0_4_, author0_.country as country0_4_, author0_.au_fname as au5_0_4_, author0_.au_lname as au6_0_4_, author0_.phone as phone0_4_, author0_.state as state0_4_, author0_.postalcode as postalcode0_4_, titles1_.au_id as au1_6_, title2_.title_id as title2_6_, title2_.title_id as title1_2_0_, title2_.advance as advance2_0_, title2_.contract as contract2_0_, title2_.notes as notes2_0_, title2_.price as price2_0_, title2_.pubdate as pubdate2_0_, title2_.pub_id as pub7_2_0_, title2_.title as title2_0_, title2_.total_sales as total9_2_0_, title2_.type as type2_0_, publisher3_.pub_id as pub1_3_1_, publisher3_.city as city3_1_, publisher3_.pub_name as pub3_3_1_, publisher3_.state as state3_1_, blurb4_.au_id as au1_1_2_, blurb4_.copy as copy1_2_, author5_.au_id as au1_0_3_, author5_.address as address0_3_, author5_.city as city0_3_, author5_.country as country0_3_, author5_.au_fname as au5_0_3_, author5_.au_lname as au6_0_3_, author5_.phone as phone0_3_, author5_.state as state0_3_, author5_.postalcode as postalcode0_3_ from authors author0_ left outer join titleauthor titles1_ on author0_.au_id=titles1_.au_id left outer join titles title2_ on titles1_.title_id=title2_.title_id left outer join publishers publisher3_ on title2_.pub_id=publisher3_.pub_id left outer join blurbs blurb4_ on author0_.au_id=blurb4_.au_id left outer join authors author5_ on blurb4_.au_id=author5_.au_id where author0_.au_id=?
The spring run exception is as below: Caused by: java.sql.SQLException: S0022: Invalid column name 'title1_2_0_'. at com.sybase.jdbc3.jdbc.ErrorMessage.raiseError(Unknown Source) at com.sybase.jdbc3.tds.TdsResultSet.findColumn(Unknown Source) at com.sybase.jdbc3.jdbc.SybResultSet.findColumn(Unknown Source) at com.sybase.jdbc3.jdbc.SybResultSet.getString(Unknown Source) at org.hibernate.type.StringType.get(StringType.java:41) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:184) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:173) at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:1121) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:588) at org.hibernate.loader.Loader.doQuery(Loader.java:724) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.loadEntity(Loader.java:1881) ... 30 more
If any one already knows workaround please guide. If need more details like code please ask.
Regards,
Miten.
|