Reputation: 393
Is it possible to add a boolean field into an array table in hibernate? I know this goes against the theoretical structure of an array, but maybe there's another collection type usable with hibernate that can do this?
i.e. (for illustration purposes)
idPerson idAddress indx currentlyResident
2 32 0 1
where idPerson is key
indx is index
idAddress is many-to-many
Thanks!
edit: This boolean value needs to be saved as part of the cross-reference table
Hibernate Mapping is very standard, just need to get an extra property in there!
<array name="addresses" table="personAddressCrossReference" cascade="all">
<key column="idPerson" />
<index column="indx" />
<many-to-many column="idAddress" class="etc." />
</array>
Upvotes: 1
Views: 341
Reputation: 16060
Yes you can. Add a attribute to your class and set it transient:
http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/#entity-mapping-property
you have to calculate and set the value yourself. You may use the @PostConstruct annotation.
Upvotes: 2