wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Can I use EJB3 and EntityManager to access databases without an ORM? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Can I use EJB3 and EntityManager to access databases without an ORM?" Watch "Can I use EJB3 and EntityManager to access databases without an ORM?" New topic
Author

Can I use EJB3 and EntityManager to access databases without an ORM?

John Chumley
Greenhorn

Joined: May 31, 2014
Posts: 4
I don't want to use an ORM like Hibernate. Maybe I have to use something from Oracle. I don't know. If I use EJB3 and the EntityManager, will that implement the JPA standard, so I can write regular SQL queries. I like using raw SQL, but I don't want to embed SQL in my program. If my ideas are wrong on what the EntityManager is, I'm trying to figure out that too.

Main thing is no embedded SQL so that I don't have to recompile each time I change something. If I use JDBC that's fine, but again I don't want to have to recompile each time.
No ORM (at least not Hibernate, TopLink, etc.) I understand what an ORM is, the mismatch between objects and relational data. I just don't want to use one.


Can I have the best of both worlds?
Will I have to make my own DAL?


Thanks for any help.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

EJB 3 uses JPA for EntityManager. Standalone Java also uses JPA for EntityManager. EntityManager is an interface. JPA/EntityManager *are* an ORM. So by definition, the answer to your question is "no."

You could use JDBC and put the SQL queries in a property file.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
John Chumley
Greenhorn

Joined: May 31, 2014
Posts: 4
Jeanne Boyarsky wrote:EJB 3 uses JPA for EntityManager. Standalone Java also uses JPA for EntityManager. EntityManager is an interface. JPA/EntityManager *are* an ORM. So by definition, the answer to your question is "no."

You could use JDBC and put the SQL queries in a property file.


If I do that last one and say read my queries from an xml file, is that something that's not usually done? Is it a bad way of doing things?

Does that mean I will have to build my own DAL to make relational data objects?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

John Chumley wrote:If I do that last one and say read my queries from an xml file, is that something that's not usually done? Is it a bad way of doing things?

Most people use a property file, not XML. But it is ok.

John Chumley wrote:Does that mean I will have to build my own DAL to make relational data objects?

Yes. If you don't want a framework to do it for you (that's what an ORM framework does), you have to do it yourself if you want it done.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I use EJB3 and EntityManager to access databases without an ORM?
 
Similar Threads
difference between session and entitymanager
How to avoid entity binding in application startup
EJB3 or hibernate
EJB3 Entity Beans or Hibernate 3.2
Designing Table specific DAO