简体   繁体   中英

Using EntityManager with Table API

I'm working on a Java webapplication and want to access the database (PostgreSQL) via an database API for security reasons. The API of the database is built by database functions.

How can I call the API functions with an EntityManager? I figured out a way with native queries, but I think then there is not much left of ORM. Is there a way for example to lead the entityManager.persist() method to one of the database functions?

This is not a good idea. The entire point of JPA is to standardize the way the database is accessed and mapped to the Object layer. If you want to use native DB functions then you should use JDBC, possibly via SpringJDBCTemplate or some other tool that eases some of the pain. If you really feel like punishing yourself though, you could always create your own implementation of EntityManager and use that in your classes.

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