java - Object-mapping in Spring JDBC? -
i have used hibernate , trying understand jdbc. have done loads of research on spring jdbc still not understand how create relationships between objects.
assume have product:
public class product { private long id; private string nam; private client customer; //constructor, getters , setters. }
and customer:
public class client { private long id; private string name; private list<product> products = new arraylist<product>(); //constructor, getters , setters }
the relationship between client , product @onetomany. how correctly save product , client objects in db using springjdbc? give thanks you
it create lot of sense in quite few cases not utilize total blown orm rely on lower level of abstraction, spring jdbctemplate , rowmapper. ibatis comes mind well. , create sense in big enterprise solutions.
if leave total blown orm world, have additional work yourself. example, can write sql query join, returning client fields , products of customer, , iterate through map java object. in quite few cases, code can clean have orm.
writing info more messy, if need optimize stuff has not been dirtied.
best utilize case can think of batch processing, command on info access becomes more of import , higher level of abstraction not create more productive.
java spring jdbc
No comments:
Post a Comment