LSPS documentation logo
LSPS Documentation
Using Entities

If you are creating JPA entities, make sure to add the class to the mapping file of the persistence unit for its data source.

Example configurations on SDK Embedded Server persistence.xml

8<---
    <persistence-unit name="user-unit" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>jdbc/USERS_DS</jta-data-source>
        <mapping-file>META-INF/user-entities.xml</mapping-file>
        <validation-mode>NONE</validation-mode>
---->8

user-entities.xml

8<---
<?xml version="1.0" encoding="UTF-8" ?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
  version="2.0">
    <entity class="org.eko.orderusersapp.entity.User" />
</entity-mappings>
---->8

Entity

@Entity
@Table(name = "ORDERS_USER")
public class User {
 
  @Id
  private Integer id;
  @Column(name = "FIRST_NAME")
  private String firstName;
 
  public Integer getId() {
    return id;
  }
  public String getFirstName() {
    return firstName;
  }
}