Example Adempiere JPA persistance

From ADempiere ERP Wiki

Jump to: navigation, search

Example to implement discriminator column given by Victor and Teo.

JPA approach ADempiere approach
  • Login as System Administrator
  • From Reference window, create a new reference with Name "A_Asset_Type", set the validation type as List, then go to List Validation tab, and add the following records:
    • Search Key=T1, Name=Type1
    • Search Key=T2, Name=Type2
  • Open the Table and Column window, search for "A_Asset" table, go to Column tab, and add "A_Asset_Type" column, set the reference as List, and set the reference value "A_Asset_Type", and check the "Discriminator Column" box


The Java code should be:

@Entity
@Table(name="A_ASSET")
@Inheritance(strategy=SINGLE_TABLE, discriminatorValue="AA")
@DiscriminatorColumn(name="A_ASSET_TYPE")
public class MAsset implements Serializable {
...
}
public class MAsset extends X_A_Asset {
...
}
@Entity
@Inheritance(discriminatorValue="T1")
public class MAssetType1 extends MAsset {
...
}
public class MAssetType1 extends MAsset {
...
}
@Entity
@Inheritance(discriminatorValue="T2")
public class MAssetType2 extends MAsset {
...
}
public class MAssetType2 extends MAsset {
...
}
Personal tools