开发者

Can I and should I use Eclipselink for non OR database interactions?

开发者 https://www.devze.com 2022-12-30 01:34 出处:网络
We are using Eclipselink for ORM, but we have a need for some more lightweight database interactions that are more equivalent to JDBC. My question is whether Eclipselink supports such an idiom and whe

We are using Eclipselink for ORM, but we have a need for some more lightweight database interactions that are more equivalent to JDBC. My question is whether Eclipselink supports such an idiom and whether there are any advantages of it to straight JDBC. I can see one adva开发者_C百科ntage being consistency and being able to use the existing connection handling. Others?

Specifically, what I'm looking for is something equivalent to Hibernate's Native SQL Query.


If you are using both JPQL and SQL queries in your application then JPA 2 native queries are probably the right approach. Here are some examples :

http://www.oracle.com/technology/pub/articles/vasiliev-jpql.html

If your app only uses SQL queries and updates, then ORM is just an overhead. You can get declarative transactions also differently, for example via Spring's JDBC support.


EclipseLink implements JPA - you can run SQL queries via an EntityManager. If you start running SQL queries not related to the model of your application you'll have no advantages over JDBC - on the contrary you'll be using a much heavier infrastructure. If you tie the SQL to the model however you'll have the advantage of making additional optimizations to queries utilizing the full db potential. I'm not sure if that's what you want to do however...

0

精彩评论

暂无评论...
验证码 换一张
取 消