File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
John Chumley
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 33667
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
John Chumley
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 33667
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic