Suppose I have an .xhtml page that collect Widget information from a given user. After the user enters the infomation, I have a stored procedure that will take the information and insert it into a Widget table using session.save. Now for the tricky part, when the user initially entered the information there was no database record associated with this Widget thus no primary key. After the proc performs the insert, I need to somehow associate the primary key with the current Widget object. Does hibernate provide a mechanism for this?
The worst case scenario is that you simply get back the id of the inserted or queried record. Once you have that id, as was said before, just load that object using either a DAO or the Hibernate Session itself. Then use that loaded POJO and volley it back and forth between your data layer and your web layer.
posted 11 years ago
will you still have access to the same internal hibernate features you do without using stored procedures?
I think it all depends on what your resultset returns to you.
I'm not overly experienced in this aspect, but I don't think your resultset is going to return to you any persistent objects. So, I would imagine that any persistent POJO you want would need to be loaded from the Hibernate Session, using the primary key that is contained in the resultSet being returned.
Feel free to correct me on this point, but it makes sense to me.
I'm gonna teach you a lesson! Start by looking at this tiny ad: