1

When I try to update an entry in hibernate using this method in my DAOimpl class:

public void setVoiceMailUnread(int id) {
        Session session = sessionFactory.openSession();
        Transaction transaction = null;
        VoiceMail vm = (VoiceMail)session.load(VoiceMail.class, id);
        try {
            transaction = session.beginTransaction();
            vm.setRead(false);
            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null)
                transaction.rollback();
            e.printStackTrace();
        } finally {
            session.close();
        }
    }

I receive the following error:

ERROR: ERROR: column "recording" is of type lo but expression is of type bigint Hint: You will need to rewrite or cast the expression. Position: 201

In my entity class the instance variable recording is of type Blob:

@Entity
@Table(name = "VOICEMESSAGES")
public class VoiceMail implements Serializable {
     private int uniqueId;
     private int messageNumber;
     private String directory;
     private String context;
     private String macroContext;
     private String callerId;
     private String origTime;
     private String duration;
     private String flag;
     private String mailboxUser;
     private String mailboxContext;
     private Blob recording;
     private String label;
     private Boolean read;
     private String messageId;

.....

@Column(name = "RECORDING", unique = true, nullable = false)
@Lob
@JsonIgnore
public Blob getRecording() {
    return recording;
}

public void setRecording(Blob recording) {
    this.recording = recording;
}

Perhaps I am missing something related to anotations for large objects because the recording column in the db is of type "lo". Thank you for your answers!

Semih Eker
  • 2,389
  • 1
  • 20
  • 29
skywalker
  • 696
  • 2
  • 16
  • 37
  • I think you need to add a `@id` to your index column(uniqueID). It looks like it is considering `recording` as the index column and trying to match the passed id with it. `VoiceMail vm = (VoiceMail)session.load(VoiceMail.class, id);` id is being compared to recording column – gpr Feb 24 '15 at 09:37
  • I have @id anotation of my uniqueId but I didnt put it in the code snippet because my class is really huge. Thanks! – skywalker Feb 24 '15 at 09:42
  • can you put @lob before 'recording' variable declaration? Or just remove it. – Ravi Chhatrala Feb 24 '15 at 10:10
  • Have a look at this question http://stackoverflow.com/questions/3677380/proper-hibernate-annotation-for-byte. Do check all the answers. – gpr Feb 24 '15 at 10:43

0 Answers0