-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: @SQLInsert not supporting update statement anymore
PostPosted: Wed Mar 13, 2013 12:01 pm 
Newbie

Joined: Wed Mar 13, 2013 11:32 am
Posts: 16
Hi

After upgrading to Hibernate 4.1.x it is no long possible to execute a native update statement inside @SQLInsert on a releated class.
I get this error inside: org.hibernate.persister.entity.AbstractEntityPersister.insert()
Code:
ORA-01722: invalid number

My classes look like this and "yes" table name t_error is the same in both object to enable lazy load of lobs in Hibernate ;-)
Code:
@Entity
@Table(name = "t_error")
@SQLInsert(sql = "update t_error set message = :message where id = :id", check=ResultCheckStyle.NONE, callable=false)
public class ErrorMessage implements Serializable {

    private static final long serialVersionUID = 1L;
   
    @Id
    @Column(name="id")
    private Long id;

    @OneToOne
    @GeneratedValue(generator = "foreign")
    @GenericGenerator(name = "foreign", strategy = "foreign", parameters = { @Parameter(name = "property", value = "error") })
    @JoinColumn(name = "id", referencedColumnName="id", insertable=false, updatable=false)
    private Error error;

    @Lob
    @Column(name = "message", nullable = true)
    private String message;

    @PrePersist
    public void prePersist() {
        if (id == null)
            id = error.getId();
        this.setError(error);
    }

    @PreUpdate
    public void preUpdate() {
        if (id == null)
            id = error.getId();
    }
}


Code:
@Entity
@Table(name = "t_error")
@SequenceGenerator(name = "seq_error", sequenceName = "seq_error", allocationSize = 1)
@DynamicUpdate(true)
public class Error {

    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "id", nullable = false, unique = true, updatable = false)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_error")
    private Long id;

    @Column(name = "error_code", nullable = false)
    private Integer errorCode;

    @OneToOne(fetch = FetchType.LAZY, optional = true, cascade = CascadeType.ALL, mappedBy="error")
    @NotFound(action = NotFoundAction.IGNORE)
    @Fetch(FetchMode.SELECT)
    private ErrorMessage errorMessage;

    @Column(name = "severity", nullable = false)
    private Integer errorSeverity;

    @Column(name = "error_text", length = 200, nullable = false)
    private String errorTextStatic;

    @Column(name = "error_type", length = 20, nullable = false, insertable = false, updatable = false)
    private String errorType;

    @PrePersist
    protected void onPersist() {
        errorMessage.setError(this);
    }

    @PreUpdate
    protected void onUpdate() {
        errorMessage.setError(this);
    }

}


What i do is persisting the Error.class

The output from this is the following SQL statements - just as expected:

Code:
select seq_error.nextval from dual


Code:
insert  into t_error (error_code, severity, error_text, error_type, id) values (?, ?, ?, ?, ?)


Code:
update t_error set message = :message where id = :id


The create log on the last update is:

Code:
2013-03-13 17:26:59,044 63284 [main] TRACE org.hibernate.persister.entity.AbstractEntityPersister  - Dehydrating entity: [ErrorMessage#57]
2013-03-13 17:27:09,340 73580 [main] TRACE org.hibernate.type.descriptor.sql.BasicBinder  - binding parameter [1] as [BIGINT] - 57
2013-03-13 17:27:18,222 82462 [main] TRACE org.hibernate.type.descriptor.sql.BasicBinder  - binding parameter [2] as [CLOB] - Test single error message
2013-03-13 17:27:31,911 96151 [main] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper  - ORA-01722: invalid number


I assume this has something to do with the way values are binded not using names but indexes?

Does anyone know how to get this working?

Br. Jesper


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.