Hibernate @transient switch

I have a mapped superclass that has a field that has some of the tables in my shared folder.

I want to annotate this field with @Transient, so most objects will ignore it, but de-@Transient or un- @Transient is on child objects.

Is it possible?

Thanks Idob

+7
source share
1 answer

You may be able to use the discriminator pattern

http://docs.jboss.org/hibernate/orm/3.3/reference/en-US/html/mapping.html

You will need to create a parent superclass and then subclass it, something like

ClassWithSharedFields ClassExtensionThatUpdatesCertainFields ClassExtensionThatReadsCertainFields 

Then ClassExtensionThatReadsCertainFields can specify a field that you do not plan to update, only as read.

This may be a slightly vague sentence, so if you want more specific help, you might want to provide some more specific examples of how your domain classes should behave in relation to your database.

+1
source

All Articles