• Post Reply Bookmark Topic Watch Topic
  • New Topic

Do people still use plain JDBC to do many to many mapping ?  RSS feed

 
tangara goh
Ranch Hand
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi experts,

I have this nagging question in my mind which I hope to get some answers.

My question : does people still use plain java jdbc to handle many-to-many relationship table nowadays ?

I have tried so hard to find some example and all google gave me is JPA, hibernate and Spring jdbc template or MyBatis etc.

Is this the way forward to do things nowadays cos I find that I may be in the wrong direction..... and hope to get out of the wrong path.....

 
Tim Moores
Saloon Keeper
Posts: 3834
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are probably still folks who write JDBC code to handle this, but both JPA and Hibernate are popular (and, IMO, preferable) approaches to ORM.
 
Mohammed Sardar.
Ranch Hand
Posts: 164
1
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recently I heard one of the 30 years old product has start to replace from JDBC to JOOQ (ORM Tool)!!! Initially it was COBOL command driven application  then migrated to great Java.
 
tangara goh
Ranch Hand
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:There are probably still folks who write JDBC code to handle this, but both JPA and Hibernate are popular (and, IMO, preferable) approaches to ORM.


Tks Tim.  I think this should be the direction I have to be heading cos I really find JDBC tough to handle when comes to many to many relationships and as the app get more and more of these relationships, it may get tougher and tougher.  Correct me if I am wrong cos I don't have a chance to experience what is the real world java is about. 

Can I know if JPA works well with normal Tomcat ?  Or must I use Tomcat EE ? cos I know glassfish is expensive when come to hosting....



 
Tim Moores
Saloon Keeper
Posts: 3834
80
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JPA works fine on the standard Tomcat.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37181
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mentioned JDBC Template. You still have to write the SQL when using JDBC template. It just manages the plumbing a bit more for you.
 
L Foster
Ranch Hand
Posts: 242
14
Android Angular Framework AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all.

This many-to-many scenario, when done via JDBC, would tend to reflect the way SQL queries or inserts are carried out against such an arrangement.  There would be one (probably two) joins to navigate from the row in one side of the relationship, to its children rows in the other side (traversing the relationship table between).  Populating such a table would also look like SQL inserts.

The ORMs make things more convenient, and will probably take less code; you will have fewer "dumb copy" commands to move things out of result sets, when querying.  You will not have to call the "insert" method explicitly across all three tables when putting data in.

However to answer the question plainly, I am pretty sure Hibernate will be implemented under the covers, in JDBC.  So if you can do it in an ORM, you can do it in JDBC.  And I have encountered code written by others on my team that was in JDBC--written only about a year ago, albeit with a less complex scenario.

I Hope it Helps
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!