Page 5 of 5 FirstFirst ... 345
Results 41 to 45 of 45

Thread: Use Hibernate Entities in the web layer?

  1. #41

    Default

    The only reason they are initialized is for the Spring binder to work properly using them as command objects. This to me seems like a pretty good reason not to use Hibernate entities as command objects

  2. #42
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    Quote Originally Posted by alwaysLearning View Post
    The only reason they are initialized is for the Spring binder to work properly using them as command objects. This to me seems like a pretty good reason not to use Hibernate entities as command objects
    As I implied when saying it is already an error on the Java level: It has nothing to do with Hibernate. You would get the same error with DTOs. In your case it seems to be better to put that code into the controller instead of the domain objects, especially since it is a requirement of the web framework, not your domain.

    Joerg
    This post can contain insufficient information.

  3. #43
    Join Date
    Mar 2008
    Posts
    1

    Default

    This might have been repeated before but wanted to run by to see that my assumptions are correct

    Deciding whether to use DTO's or not to use them have been bothering me before I started my current work. And having known some of the issues with this approach, I've used my domain objects in the presentation layer.
    But, have reached a stage where in I'm regretting my choice of doing it.
    The problem mainly is when using domain entities (with one-to-one relation to other entities) in presentation layer (JSF). When the child entity is not available for the parent entity, it would be set to null by the ORM. This causes the problem because the binding on the presentation layer (JSF) calls some setters on the nested child entity and that throws "null" validation problems.

    I think DTO's are required if the domain entities are editable from presentation layer. DTO's could be ignored for entities that might be used for only rendering info. Agreeing to what was said in the Hibernate in Action book.

    Any feedback is much appreciated.

  4. #44
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Quote Originally Posted by MMR View Post
    ...When the child entity is not available for the parent entity, it would be set to null by the ORM. This causes the problem because the binding on the presentation layer (JSF) calls some setters on the nested child entity and that throws "null" validation problems.
    ...
    And how DTO would help? If child entity is null in the domain object why DTO may contain something else?

    Regards,
    Oleksandr

  5. #45
    Join Date
    Nov 2005
    Posts
    5

    Default

    Just do it. I have finished this thought.
    http://code.google.com/p/rich-hibernate-lazy/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •