EJB3.0 Development Guide: Inheritance of Entity Bean: Joint Table Policy

xiaoxiao2021-03-06  52

This and single-form strategy is similar, and the only difference is that each entity bean is mapped to a separate table when it is stored.

Such as:

@Entity

@Inheritance (strategy = inheritancetype.joined, discriminatortype = discriminatortype.string)

@DiscriminatorColumn (name = "p_type", nullable = true)

Under this strategy, each entity bean is also mapped into a separate table, but it is different from each type of table policy that there is only a new attribute in the mapping of the subform bean.

Subform beans are data by a joint parent table.

@InheritanceJoinColumn and @inheritancejointJointColumns are used to specify a federated column name. If not specified, the foreign key will use the same name as the parent table master key.

This example mainly has the following documents, this example mainly implements the inheritance relationship between Person and Man, Woman. This example is not much different from the previous example, that is, in the entity bean comment, change inheritancenesstype.single_table.

InheritanceType.joined

Run {$ jboss_home} / bin's run.bat: run -c all, start JBoss.

HTTP: // localhost: 8080 / jmx-console / htmladaptor? action = inspectMben & name = jboss% 3AService% 3DHYPERSONIC% 2CDATABASE% 3DLOCALDB, then call the StartDatabaseManager () method to open the HSQL Management Tools Management Database.

Execute the EJBJAR TARGET in the ANT view of Eclipse. Or in the command line, enter this project directory, perform Ant Ejbjar, publish this EJB.

Execute Run Target in the ANT view of Eclipse. Or on the command line, enter this project directory, perform Ant Run, test this EJB.

转载请注明原文地址:https://www.9cbs.com/read-81451.html

New Post(0)