Home

 

Transaction entity

Example | -7 shows an extract of the Transaction class.

Example 12-7 Transaction entity

@Entity
@Table(name="TRANSACT")
public class Transaction implements Serializable {
	@Id
	private String id;

	@Column(name="TRANS_TYPE")
	private String transType;

	@Column(name="TRANS_TIME")
	private Timestamp transTime;

	private BigDecimal amount;

	@ManyToOne
	private Account account;

	......
	// constructor, getter, setter methods

The @Entity annotation defined the class as an entity.

The @Table annotation defines the mapping to the TRANSACT table. Note that the schema name (ITSO) is missing. The other two classes have no @Table annotation because the entity name is identical to the table name.

The @Id annotation defines id as the primary key.

The @Column annotation maps the fields to a table column if the names do not match.

The @ManyToOne annotation defines the m:1 relationship with Account. The mapping defaults to account_id as the column name.
ibm.com/redbooks