简体   繁体   中英

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

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 advantage 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 .

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...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM