Hi guys! I'm new to Java and I'm now studying Spring + Hibernate. In the samples I found on the web there were business objects with methods like:
The UserDao class is a bean injected from Spring and would make the call to hiberate and stuff.
But that's not rights is it? I mean, this is coupling the data access layer with your business model. From what I can remember the business model should not know about about dao's. Or is it? It's true I can think of some situations where injecting the dao in the business class would come in handy but that's just because i don't know more about hibernate.
Thanks in advance and sorry if my question is silly
Isn't this a case where the dao knows the domain object, but the domain objects still don't know about the daos. Couldn't you also have Spring inject the domain objects into the daos?
well the point was that you usually have one dao and many domain object. you can't inject them all in the dao. you don't even know when they'll get instantiated
Cristian Vrabie
Ranch Hand
Joined: Jul 09, 2008
Posts: 71
posted
0
actually i might be mistaken. one layer should be allowed to know only about the layer directly below and dao is directly under domain layer. so it actually could be correct. i just got confused because i saw different implementations of the same sample problem in many different ways.