-->
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: How to tell hibernate that systimestamp takes a parameter?
PostPosted: Sun Oct 20, 2013 6:54 pm 
Newbie

Joined: Sun Oct 20, 2013 6:44 pm
Posts: 2
I have the following query
Code:
update Device d set d.activationTs = :activationTs, d.lstUpdTs = SYSTIMESTAMP, d.lstUpdBy=:lstUpdBy where d.deviceServiceId=:serviceId


on oracle this is giving me 6 places after the decimal point for seconds. I need to reduce this to millisecond precision, so 3 numbers after the decimal place.

In a raw SQL session, i can pass a paramter to SYSTIMESTAMP to achieve this, but hibernate is incorrectly telling me that systimestamp takes no parameters. E.g.
Code:
select systimestamp(3) from dual;


Is there anyway i can pass the required precision to systimestamp when using hibernate?

Thanks,
Dan.

Code:
Caused by: org.hibernate.QueryException: function takes no arguments: systimestamp [update nz.co.vodafone.cmdb.model.Device d set d.activationTs = :activationTs, d.lstUpdTs = SYSTIMESTAMP(3), d.lstUpdBy=:lstUpdBy where d.deviceServiceId=:serviceId]
   at org.hibernate.dialect.function.NoArgSQLFunction.render(NoArgSQLFunction.java:66) ~[hibernate-core-4.2.5.Final.jar:4.2.5.Final]
   at org.hibernate.hql.internal.ast.SqlGenerator.endFunctionTemplate(SqlGenerator.java:220) ~[hibernate-core-4.2.5.Final.jar:4.2.5.Final]
   at org.hibernate.hql.internal.antlr.SqlGeneratorBase.methodCall(SqlGeneratorBase.java:2326) ~[hibernate-core-4.2.5.Final.jar:4.2.5.Final]


Top
 Profile  
 
 Post subject: Re: How to tell hibernate that systimestamp takes a parameter?
PostPosted: Sun Oct 20, 2013 7:50 pm 
Newbie

Joined: Sun Oct 20, 2013 6:44 pm
Posts: 2
In case anyone with the same issue finds this post, i have solved my problem by reducing the precision of the column the timestamp is saved in to timestamp(3), that way the database rounds down the 6 decimals returned by systimestamp to 3.

It remains however that hibernate should allow passing a parameter to the systimestamp function.


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.