Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is spring DAO module a ORM?

 
VinodhKumar Srinivasan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Buddies,
This a question came in to mind , when I look ed spring modules. I thing Spring DAO layer is actually a ORM. Wait I can prove it ... What is an ORM- It provides you a 1. Database connectivity,2. Mapping DB objects to Java Objects and 3. Transaction management. So this Spring DAO is a ORM.

The ORM module in spring has to be renamed as something else may be Plug your own ORM :-) or .....


What you say ?

Thanks,
Vinodh
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, Spring offers integration to ORM, but it's no ORM.
http://static.springsource.org/spring/docs/2.5.x/reference/orm.html

And you misunderstand, database connectivity and transaction management are not exclusive features of ORM, otherwise pure JDBC can be considered as an ORM solution.

Spring's JDBC abstraction framework doesn't map relational data and objects in a way ORM solutions do either.
 
VinodhKumar Srinivasan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kengkaj ,
Thanks for your quick reply. I want to know ORM in simple words. That is what is ORM?

-Vinodh
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
VinodhKumar Srinivasan wrote:Kengkaj ,
Thanks for your quick reply. I want to know ORM in simple words. That is what is ORM?

-Vinodh


Object Relational Mapping, or mapping your Java objects to a relational database.

We have an ORM forum too, near the top of the forums list.

Mark
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ORM is no standardize term yet. If we just take it literally (Object-Relational Mapping), using JDBC and create an object from an SQL result set is ORM.

However in widely accepted meaning, an ORM solution maps object to relational data using metadata like XML or Annotations, it also offers a query language that maps to SQL.

Hope this helps.
 
VinodhKumar Srinivasan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kengkaj,

Fine explanation. Here Spring JDBC gives
1.configuration files(connection, DAO injection),
2.It uses reflection to load the Java Objects from DB layer.
3. It doesn't give query language that is we have to write the native SQL query.
is the 3rd point makes Spring JDBC Just a abstract layer of JDBC?

Thanks,
Vinodh


 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
VinodhKumar Srinivasan wrote:Kengkaj,

Fine explanation. Here Spring JDBC gives
1.configuration files(connection, DAO injection),
2.It uses reflection to load the Java Objects from DB layer.
3. It doesn't give query language that is we have to write the native SQL query.
is the 3rd point makes Spring JDBC Just a abstract layer of JDBC?

Thanks,
Vinodh




Spring JDBC is kind of just that, the classes help in writing JDBC code, but there is also Spring integration with all the major ORM products, like Hibernate and Top Link.

Mark
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
VinodhKumar Srinivasan wrote:Kengkaj,

Fine explanation. Here Spring JDBC gives
1.configuration files(connection, DAO injection),
2.It uses reflection to load the Java Objects from DB layer.
3. It doesn't give query language that is we have to write the native SQL query.
is the 3rd point makes Spring JDBC Just a abstract layer of JDBC?

I don't know what you mean by "uses reflection". But Spring's JDBC abstraction framework doesn't use metadata to map objects to relational data, so it is not an ORM solution.
You can read more about Spring Framework's JDBC abstraction framework at http://static.springsource.org/spring/docs/2.5.6/reference/jdbc.html.
 
VinodhKumar Srinivasan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree the point. It is not full fledged ORM. It doesn't provide much meta data things.

-- Refection - Spring would load java objects for us. For this we don't have any specific mapping (like hbm file in hibernate). Instead the simple rule is you have to have java attributes same as your table fields. When we call the JDBC API, You can pass the SQL and java pojo. Then Spring would load the java object, this is done through reflection.



- So the Spring JDBC is like ORM but doesn't support all feature.

- Thanks to all who replied to this post.


 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
VinodhKumar Srinivasan wrote:
- So the Spring JDBC is like ORM but doesn't support all feature.

It's only your opinion which is affected from your point of view about ORM. I don't think Spring JDBC is like ORM at all, developers still do most of the mappings.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kengkaj Sathianpantarit wrote:
VinodhKumar Srinivasan wrote:
- So the Spring JDBC is like ORM but doesn't support all feature.

It's only your opinion which is affected from your point of view about ORM. I don't think Spring JDBC is like ORM at all, developers still do most of the mappings.


I agree, Spring JDBC is not an ORM.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic