Answer the question
In order to leave comments, you need to log in
Links in jpa don't work. How to describe entity relationships?
Er table diagram:
Data Model:
Table - J_MESSAGE_PARAM
@Entity
@Table(name = "J_MESSAGE_PARAM", schema = "PKU")
@EqualsAndHashCode
@ToString
public class PkuJMessageParam implements Serializable, Cloneable, IGetId {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
@Getter @Setter private long id;
@Column(name = "NAME")
@Getter @Setter private String name;
@Column(name = "VALUE")
@Getter @Setter private String value;
@ManyToOne
@JoinColumn(name = "ID")
@Getter @Setter private PkuJMessage jMessage;
}
@Entity
@Table(name = "J_MESSAGE", schema = "PKU")
@EqualsAndHashCode
@ToString
public class PkuJMessage implements Serializable, Cloneable, IGetId {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
@Getter @Setter private long id;
@Column(name = "DATA")
@Getter @Setter private byte[] data;
@Column(name = "FILENAME")
@Getter @Setter private String filename;
@Column(name = "USER")
@Getter @Setter private String user;
@Column(name = "IS_OUT")
@Getter @Setter private String isOut;
@Column(name = "IS_WORKED_OUT")
@Getter @Setter private String isWorkedOut;
@Column(name = "IS_SENT")
@Getter @Setter private String isSent;
@Column(name = "IS_RESULT")
@Getter @Setter private String isResult;
@Column(name = "DESCRIPTION")
@Getter @Setter private String description;
@Column(name = "EXECUTION_DATE")
@Getter @Setter private Timestamp executionDate;
@Column(name = "NEED_RESTART")
@Getter @Setter private String needRestart;
@OneToMany(mappedBy = "jMessage")
@Getter @Setter private List<PkuJMessageParam> jMessageParams;
}
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="PKU">
<jta-data-source>jdbc/PKU</jta-data-source>
<properties>
<property name="openjpa.Log" value="log4j"/>
<property name="openjpa.ConnectionFactoryProperties" value="PrintParameters=true" />
<property name="javax.persistence.query.timeout" value="60000"/>
<property name="openjpa.jdbc.DBDictionary" value="db2(batchLimit=50)"/>
<property name="openjpa.RemoteCommitProvider" value="sjvm"/>
<property name="openjpa.ConnectionRetainMode" value="on-demand"/>
<property name="openjpa.FlushBeforeQueries" value="true"/>
<property name="openjpa.IgnoreChanges" value="false"/>
<property name="openjpa.TransactionMode" value="local"/>
</properties>
</persistence-unit>
</persistence>
@PersistenceContext(unitName = "PKU")
private EntityManager manager;
public T read(long id) {
LOG.debug(Conv.toFillTextMsg("Читаю объект {0} (id={1})", getClassName().getSimpleName(), id));
long t = System.currentTimeMillis();
T item = manager.find(getClassName(), id);
manager.flush();
LOG.debug(Conv.toFillTextMsg("Прочитан объект {0} : [{1}]. Время выполнения {2} мс.", getClassName().getSimpleName(), item, System.currentTimeMillis()-t));
return item;
}
Answer the question
In order to leave comments, you need to log in
It wasn't the code, it was the EJB configuration for IBM WebSphere.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question