I went through hbcontainer example, and it works well. However,
would it be possible to use hbcontainer with tables which participate in more complex relationships? For instance if the take the example from http://dev.itmill.com/wiki/Articles/UsingHibernateWithToolkit
and if we wanted to add a child collection of objects “WorkoutDetail” (all actions performed during one workout) to the Workout object, so that there is one to many relationship between the Workout and WorkoutDetail, then how would we persist that to the database using HbContainer?
I tried something like that, but I am getting
javax.servlet.ServletException: org.hibernate.PropertyValueException: not-null property references a null or transient value
I’m sorry to answer bit late. I’m not sure if the issue is still there or did you got it solved already?
I have never used HbnContainer for any real application (I have lately just been hacking the framework). When I wrote the original article relations to different tables got to my mind, but didn’t find the time to develop a proper way to handle them. I was supposed to resolve the issue bit later, but have been too busy elsewhere. I think the lack of proper relation support is the most critical issue in HbnContainer, I haven’t heard any other problems lately.
In one project in IT Mill they implemented relations by populating selects manually. Not the most fine grained solution, but it works if you only have some relations. To use HbnContainer (with relations) fluently for example in Form, we’d need to develop HbnContainer a bit further.
The current version doesn’t really support relations. One can retrieve the referenced object, but this is not the correct behaviour. The problem is that Property.getValue() in HbnContainer always returns the actual value, which with Hibernate is the object reference. To reflect Container-Item-Property datamodel used in Toolkit, Property in HbnContainer should return the identifier of referenced entity instead (in case of oneToMany relation). For ManyToOne of manyToMany we’d need the same kind of changes and the Property value should be a set of identifiers.
After these changes it ought to become much simpler to to hook data to UI.
I’ll hope to find some time to develop this further soon, but I’m also eager just to review and commit patches
I did some enhancements to HbnContainer to incubator. Now the workoutlog example has an other entity type, which is referenced form workout. It containes examples for manytoone and manytomany relations.
Had to fix one bug in Table component and code some ugly Hibernate and reflect code, but in this minor test case things seems to work as I suggested.
The article itself is not yet updated.
I hope this helps forward. You may need to tune the code a bit for your usage. Please share your enhancements!