-->
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.  [ 3 posts ] 
Author Message
 Post subject: Use Hibernate's SQL Dialect functionality without OR-mapping
PostPosted: Wed Jan 16, 2008 5:30 am 
Newbie

Joined: Wed Jan 16, 2008 5:15 am
Posts: 2
Hi,

I need to port an application from oracle to multiple datbases support (mssql, db2, oracle as the first goal).

The application does not need an OR mapping. It uses SQL which are a little bit more complex than standard SQL (e.g. oracles NVL).

For instance, I want to write one SQL like

select 'some con' || 'cat string', coalesce('its null', somevalue), current_timestamp() from mytable order by someothervalue

Can I use hibernate dialect implementation to translate that into different SQL dialects?

I know hibernate is ment to be an OR mapping. I found SwisSQL which does this job, but its very expensive.


thanks,
michael


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 2:11 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
pretty much all you describe in that query can be achieved in Hibernate.
Hibernate HQL does have current_time functions, coalesce and concat.

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 17, 2008 6:41 am 
Newbie

Joined: Wed Jan 16, 2008 5:15 am
Posts: 2
OK. I find some things out now. But I''m still not sure...


My current HQL query is
select coalesce('its null', somevalue), current_timestamp() from IdObject order by someothervalue

In my hibernate configuration I can switch the Dialict and it works.

But:
- I need an "dummy object" with an mapping (here: IdObject) for each table I query. The class IdObject has only an String id with a getter and setter method and the mapping file. Can I avoid this without getting a "Table (object) XXX is not mapped" exception if I query an unknown table?

- I don't need the current_timestamp, I need somethink like oracle's "to_date" function. I need to create a db date value out of a string (e.g. to_date('2007-01-12 10:23:11', 'YYYY-MM-DD hh24:mm:ss'). I could not find an HQL function for that jet.


thanks,
Michi


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