Is it possible to have foreign key enforced without object-to-object mapping?

前端 未结 4 750
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-18 07:15

Assuming the following mappings are provided:


  
  

        
4条回答
  •  半阙折子戏
    2021-01-18 07:54

    I recommend you to associate objects to objects to get full advantages of Hibernate. I think the problem is the exception you get. This is because Hibernate session is already closed when you try to get the lazy object. There are several posts in this blog which show answers to this problem, for example this one:link text.

    In case you're using spring you can use OpenEntityManagerInViewFilter so the session will keep opened until the view is renderes.

提交回复
热议问题