[Hibernate-JIRA] Created: (HHH-7035) Wrong NClob cast to Blob
by stephan (JIRA)
Wrong NClob cast to Blob
------------------------
Key: HHH-7035
URL: https://hibernate.onjira.com/browse/HHH-7035
Project: Hibernate ORM
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.6.8
Environment: jpa 2
jdk 6
ojdbc6-11.2.0.2.0
Reporter: stephan
I read an entity from an Oracle 10gR2 database and the I try to write it to a Postgresql 8.3.14 dataabse.
Here the entity :
public class MyEntity {
@javax.persistence.Lob
java.sql.NClob prop;
public void setProp(java.sql.NClob c) {
prop=c;
}
public java.sql.NClob getProp() {
return prop;
}
}
When it's time to flush it to database, I get this exception :
java.lang.ClassCastException: oracle.sql.NCLOB cannot be cast to java.sql.Blob
at org.hibernate.type.BlobType.getReplacement(BlobType.java:37)
at org.hibernate.type.AbstractStandardBasicType.replace(AbstractStandardBasicType.java:359)
at org.hibernate.type.TypeHelper.replace(TypeHelper.java:212)
at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:600)
at org.hibernate.event.def.DefaultMergeEventListener.mergeTransientEntity(DefaultMergeEventListener.java:337)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:303)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:464)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:255)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:84)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:867)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:851)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:855)
at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:851)
Hibernate should try to cast to a java.sql.Clob because oracle.sql.NClob implements java.sql.Clob
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Commented: (HHH-1570) criteria-api: filtering by key-many-to-one causes invalid sql
by Yoann Antoviaque (JIRA)
[ https://hibernate.onjira.com/browse/HHH-1570?page=com.atlassian.jira.plug... ]
Yoann Antoviaque commented on HHH-1570:
---------------------------------------
I attached my patch in case someone comes here and needs it...
> criteria-api: filtering by key-many-to-one causes invalid sql
> -------------------------------------------------------------
>
> Key: HHH-1570
> URL: https://hibernate.onjira.com/browse/HHH-1570
> Project: Hibernate ORM
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.5.3, 3.6.0.Beta1
> Reporter: Joris Verschoor
> Assignee: Steve Ebersole
> Attachments: HHH-1570-fix-composites.diff, HHH-1570-fix.patch, HHH-1570-it.patch, hibernate.patch
>
>
> We have a class Price that has a composite-id using a couple of key-properties and some key-many-to-ones)
> One of those is "transportation", which has a many-to-one to transportationType
> When we query using: criteria.add(Expression.eq("price.transportation.transportationType.id", transId);, we get an invalid SQL statement: The table of transportation was not selected.
> I will try to make a testcase today or tomorrow, depending on my schedule.. Things will be more clear by then...
> We have created a work-around, by mapping the transportationID twice: once in key-property, and once as a many-to-one. (instead of one key-many-to-one)
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Updated: (HHH-1570) criteria-api: filtering by key-many-to-one causes invalid sql
by Yoann Antoviaque (JIRA)
[ https://hibernate.onjira.com/browse/HHH-1570?page=com.atlassian.jira.plug... ]
Yoann Antoviaque updated HHH-1570:
----------------------------------
Attachment: HHH-1570-fix-composites.diff
patch based on HHH-1570-fix.patch which was not working in our case with multiple association in the same composite key
> criteria-api: filtering by key-many-to-one causes invalid sql
> -------------------------------------------------------------
>
> Key: HHH-1570
> URL: https://hibernate.onjira.com/browse/HHH-1570
> Project: Hibernate ORM
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.5.3, 3.6.0.Beta1
> Reporter: Joris Verschoor
> Assignee: Steve Ebersole
> Attachments: HHH-1570-fix-composites.diff, HHH-1570-fix.patch, HHH-1570-it.patch, hibernate.patch
>
>
> We have a class Price that has a composite-id using a couple of key-properties and some key-many-to-ones)
> One of those is "transportation", which has a many-to-one to transportationType
> When we query using: criteria.add(Expression.eq("price.transportation.transportationType.id", transId);, we get an invalid SQL statement: The table of transportation was not selected.
> I will try to make a testcase today or tomorrow, depending on my schedule.. Things will be more clear by then...
> We have created a work-around, by mapping the transportationID twice: once in key-property, and once as a many-to-one. (instead of one key-many-to-one)
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months