Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7429693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:00:43+00:00 2026-05-29T09:00:43+00:00

Here is my entity : public class MyEntity { @javax.persistence.Lob java.sql.NClob prop; public void

  • 0

Here is my 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)

Why does Hibernate try to cast it to java.sql.Blob ?
Can I specify another type instead of java.sql.Blob (java.sql.Clob) ?

JDK 6
JPA 2
Hibernate 3.6.8.Final
Oracle 10.2g
Postgresql 8.3 (The entity is read from an Oracle database and then write to a Postgresql database)

I have opened a bug on this on JIRA

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:00:44+00:00Added an answer on May 29, 2026 at 9:00 am

    Here how I solve my problem :

    public class MyEntity {
       @Column(length=100000)
       String prop;
    
       public void setProp(String c) {
           prop=c;
       }
    
       public String getProp() {
           return prop;
       }
    }
    

    In my case the arbitrary value 100000 is really enough to handle the values the application will deal with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my Entity Class public enum UnitType { HOSPITAL, HEALTHCENTER } public static
This is how my entity class looks: @Entity @Unindexed public class User { ...
Given the following entity- public class Friend { public virtual string Name { get;
I have two entities like the following: @Entity public class Trip { @OneToMany(mappedBy =
I have a Formula defined as: @Entity @Table(name = MyEntity) @org.hibernate.annotations.Table(appliesTo = MyEntity) public
If i have the following entity: public class PocoWithDates { public string PocoName {
Here's what I'm trying to do : I have an entity Task with a
here is my xml DOM. <entities> <entity id=7006276> <title>xxx</title> <entities> <entity id=7877579> <title>xxx</title> <entities>
Why is twitter double encoding XML entity references? Here's an example tweet: xml entity
I've got a LINQ query going against an Entity Framework object. Here's a summary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.