-->
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.  [ 2 posts ] 
Author Message
 Post subject: @SQLInsert with current_timestamp function
PostPosted: Tue Jul 06, 2010 5:22 pm 
Newbie

Joined: Tue Jul 06, 2010 5:06 pm
Posts: 2
Hi, I am running into trouble using @SQLInsert annotation and inserting a current_timestamp. I have tried the following:

Code:
@SQLInsert(sql = "INSERT INTO MY_TABLE(id, value1, date1) values (?, ?, current_timestamp)
@SQLInsert(sql = "INSERT INTO MY_TABLE(id, value1, date1) values (?, ?, (select current_timestamp from dual))


I am getting an ORA-01722: invalid number error. When I copy/paste the corresponding generated SQL from the log to SQLDeveloper, the statement executes without error (obviously after filling the parameters).

I assume I am missing something small here, any ideas? I am using Hibernate 3.2.6 with Hibernate Annotation 3.3.1 and Oracle with Oracle10gDialect If any more info is required I will provide it.

Here is a simplified version of the code....

Code:
@Entity(name = "MyClass")
@Table(name = "MY_TABLE")
@SQLInsert(sql = "INSERT INTO MY_TABLE(id, value1, date1) values (?, ?, current_timestamp)
public class MyClass {
   
   @Column(name = "DATE1", insertable = false)
   private Date date;

   @Column(name = "VALUE1")
   private String value;
}


TIA,

- Steve


Top
 Profile  
 
 Post subject: Re: @SQLInsert with current_timestamp function
PostPosted: Wed Jul 07, 2010 10:15 am 
Newbie

Joined: Tue Jul 06, 2010 5:06 pm
Posts: 2
NM, fixed my issue using @Column(....., columnDefinition = "timestamp(6) default current_timestamp)


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

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.