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.  [ 4 posts ] 
Author Message
 Post subject: [2.0] server date
PostPosted: Wed Sep 17, 2008 12:55 pm 
Newbie

Joined: Wed Jul 02, 2008 7:54 am
Posts: 8
Location: Brussels
Hello,

I Just want to recover the server date.

If I do a query like that :


Code:
return sess.CreateQuery("select current from User")
                    .SetMaxResults(1)
                    .List<DateTime>()[0];


It doesn't work.

So what the solution please?

Thank you in advance


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 3:46 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
You have to post a bit more information if you want help. At least the error message you get, check the inner exception. Parts of the mapping.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 8:39 am 
Newbie

Joined: Wed Jul 02, 2008 7:54 am
Posts: 8
Location: Brussels
Sorry I just wanted to know if it's possible to recover the server date with a NHibernate behavior

Finally I create it my slef :

I created a View

Code:
create view "informix".date_system_view (today) as select TODAY
from "informix".systables x0 where (x0.tabid = 1 )


and I Created my object just for the date :

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-access="property" default-lazy="true">
  <class name=".......DomainModel.DateSystemView, DomainModel" table="date_system_view" batch-size="30" >
    <id name="Today" type="DateTime" column="today" unsaved-value="none">
      <generator class="assigned" />
    </id>
  </class>
</hibernate-mapping>


So When I want to know the server date I just have to write :

Code:
((DateSystemView)sess.CreateQuery("from DateSystemView").UniqueResult()).Today;


I'm sure it's possible easier but I don't know how


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 8:47 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
You can use a SQLQuery for this.

Code:
DateTime today = session.CreateSQLQuery("select today from informix.systables x0 where x0.tabid = 1")
   .AddScalar("today ", NHibernateUtil.Date)
   .UniqueResult<DateTime>


http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/querysql.html#querysql-creating

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.