Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate column formula

 
vinora kumar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi peoples,

with the property field, formula tag can we write query directly which deals with multible tables?
is it HQL or SQL?
what is the impact for DB migration. say for examble from mysql to oracle?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the Hibernate documentation:

formula (optional) an arbitrary SQL expression that is executed when a type has to be evaluated. Allows content-based discrimination.

So, yes you can write pretty much what you like in there. The impact on migration depends on the query you use.
 
vinora kumar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am lokking for an option which has no impact during migration
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In which case you will need to be very careful with the SQL you use. Or you could perform the same logic in HQL/Criteria in your DAO layer.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am lokking for an option which has no impact during migration


Migration always has an impact.

This really depends on how complicated your query is. As was mentioned, using the Criteria API (tutorial here) will allow you to write your code using your Java objects, and remove a dependency on your database structure. Of course, SQL is pretty standard, so assuming your query isn't overly complicated, you should be fine.

Of course, if someone goes and changes the structure of your database, there's not much you're going to be able to do, criteria or SQL formula solution.

-Cameron McKenzie
 
vinora kumar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks. its really helped
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic