Reputation:
I am struck with a problem while using hibernate. The situation is :
I am creating a container and in that container i am adding 2 components. one component
is a newly created component and the other one is already existing in the database.i am
getting an exception when i try to save the container. i get transient object exception.
I tried giving cascade options as refresh but that doesnt work.
Thanks and Regards, Rima Desai
Upvotes: 2
Views: 4959
Reputation: 3405
Transient object exception happen when a non-transient object (which is managed by the hibernate session) references an object that is not managed by the session. In your case I believe the container is referencing the new object.
did you call session.Save(newObject);
?
Alternatively you can mark the relationship between the container as "cascade=save" to that saving it will cause the session to save its related objects.
Upvotes: 2