• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 1021
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.....

 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 285
2
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1021
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7582
176
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JPA works fine on the standard Tomcat.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 270
15
Android Angular Framework Spring AngularJS Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic