0

I have a hibernate mapping class that maps an existing java class (say A) to a table. One of the attributes of the java class is another java class (say AA )that is mapped using the component attribute in the hibernate mapping file. There is only one attribute in class AA, which is mapped to a property from the table. I would like to know what happens when that property is empty in the table. Would an instance of class AA be created and in the final object of class A when the mapping is being executed? In my code I am seeing that the instance is not created and that attribute of Class A remains null. Is there a way to specify a parameter in the hibernate mapping file to instantiate the object nevertheless(even if its mapping property is empty in the table).

I am using Java 1.6 and hibernate 3

Thanks.

1 Answer 1

2

Based on Hibernate Guide,

The null value semantics of a component are ad hoc. When reloading the containing object, Hibernate will assume that if all component columns are null, then the entire component is null. This is suitable for most purposes. 

But as a potential workaround, You can add some sql formula for the property, so it will make sure AA instance is created.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.