This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Generic way of writing @SqlInsert ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Generic way of writing @SqlInsert ?" Watch "Generic way of writing @SqlInsert ?" New topic

Generic way of writing @SqlInsert ?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436

I'm using Hibernate 4.0.1.Final. I have a table with a unique column ...

In my DAO, I'd like to be able to write a "createOrUpdate" method such that if there is an object matching the unique key, all I do is update that object, otherwise, a new object is created. I wanted to use the @SQLInsert annotation for this ...

However, in some JUnit tests, we use the HSSQL in-memory database, whereas in other cases we use MySQL 5.5. Is there a less vendor-specific way to accomplish the @SQLInsert without resorting to vendor-specific SQL?

Thanks, - Dave
Have you checked out Aspose?
subject: Generic way of writing @SqlInsert ?
It's not a secret anymore!