EclipseLink2.1.3とWebLogic10.3.5コンテナ管理トランザクションを使用して、Oracle11gDBとインターフェイスします。
問題なくデータを選択できますが、エンティティを永続化できません。
ログに発生した例外やエラーはありませんが、ANNOUNCEMENT_DELIVERY_LOGテーブルにコミットされたデータはありません。
AnnouncementDeliveryLogエンティティには、アナウンスエンティティとの@ManyToOne関係があります。最初に既存のアナウンスエンティティを取得し、次にクエリ結果に基づいてAnnouncementDeliveryLogエンティティを作成し、2つのエンティティを関連付けて、永続化します。
私が間違っていることや、WebLogic上のEclipseLinkからより多くのログ情報を取得する方法についてのアドバイスをいただければ幸いです。
AnnouncementDeliveryLogエンティティ:
@Entity
@Table(name = "ANNOUNCEMENT_DELIVERY_LOG")
public class AnnouncementDeliveryLog implements Serializable {
@Id
@Column(nullable = false)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="ANNOUNCEMENT_DELIVERY_LOG_SEQ")
@SequenceGenerator(name="ANNOUNCEMENT_DELIVERY_LOG_SEQ", sequenceName="ANNOUNCEMENT_DELIVERY_LOG_SEQ")
private BigDecimal id;
@Column(name = "RECIPIENT_ADDRESS ", nullable = false, unique = true, length = 240)
private String recipientAddress;
@ManyToOne
@JoinColumn(name = "ANNOUNCEMENT_ID ")
private Announcements announcement;
}
アナウンスエンティティ:
@Entity
@Table(name = "ANNOUNCEMENTS")
public class Announcements implements Serializable {
@Id
@Column(nullable = false)
private BigDecimal id;
@OneToMany(mappedBy = "announcement")
private List<AnnouncementDeliveryLog> announcementDeliveryLogList;
}
トランザクションを実行するセッションファサードSLSB:
@Stateless(name = "DeliveryEngineSessionFacade",
mappedName = "Announcements-JMSDeliveryEngine-DeliveryEngineSessionFacade")
public class DeliveryEngineSessionFacadeBean implements DeliveryEngineSessionFacadeLocal {
@Resource
SessionContext sessionContext;
@PersistenceContext(unitName = "JMSDeliveryEnginePersistenceUnit")
private EntityManager em;
private List<AnnouncementDeliveryLog> createNormalizedEmailADLsForAnnouncement(int announcementId) {
List<Object[]> rawResultList;
ArrayList<AnnouncementDeliveryLog> typedResultList = new ArrayList<AnnouncementDeliveryLog>();
Query query =
em.createNamedQuery(AnnouncementDeliveryLog.FIND_NORMALIZED_RECIPIENTS_FOR_ANNOUNCEMENT);
query.setParameter(1, announcementId);
rawResultList = query.getResultList();
for (Object[] resultElement : rawResultList) {
AnnouncementDeliveryLog adl = new AnnouncementDeliveryLog(getAnnouncementById(announcementId), (String)resultElement[1], (String)resultElement[2], "TO_SEND");
adl = persistAnnouncementDeliveryLog(adl);
typedResultList.add(adl);
}
return typedResultList;
}
public AnnouncementDeliveryLog persistAnnouncementDeliveryLog(AnnouncementDeliveryLog announcementDeliveryLog) {
em.persist(announcementDeliveryLog);
return announcementDeliveryLog;
}
public Announcements getAnnouncementById(int announcementId) {
Query query = em.createNamedQuery(Announcements.FIND_BY_ID);
query.setParameter("id", announcementId);
return (Announcements)query.getSingleResult();
}
}
SLSB呼び出しセッションファサード:
@Stateless(name = "RecipientsPopulationTimer",
mappedName = "Announcements-AnnouncementDeliveryEngine-RecipientsPopulationTimer")
@Local({RecipientsPopulationTimerLocal.class})
public class RecipientsPopulationTimerBean implements RecipientsPopulationTimerLocal {
@EJB
DeliveryEngineSessionFacadeLocal sessionFacade;
}
persistence.xml
<?xml version="1.0" encoding="UTF-8" ?>
<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_2_0.xsd"
version="2.0">
<persistence-unit name="JMSDeliveryEnginePersistenceUnit">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/announcementsDS</jta-data-source>
<class>announcements.deliveryengine.jpa.entities.AnnEmailRecipientsFlattened</class>
<class>announcements.deliveryengine.jpa.entities.AnnImRecipientsFlattened</class>
<class>announcements.deliveryengine.jpa.entities.AnnouncementDeliveryLog</class>
<class>announcements.deliveryengine.jpa.entities.Announcements</class>
<class>announcements.deliveryengine.jpa.entities.AnnouncementRecipients</class>
<class>announcements.deliveryengine.jpa.entities.AnnouncementRecipientsFlattenedId</class>
<properties>
<property name="eclipselink.target-server" value="WebLogic 10"/>
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.logging.exceptions" value="true"/>
<property name="eclipselink.logging.timestamp" value="true"/>
<property name="eclipselink.logging.thread" value="true"/>
<property name="eclipselink.logging.session" value="true"/>
<property name="eclipselink.logging.level.sql" value="FINE"/>
<property name="eclipselink.logging.parameters" value="true"/>
<property name="eclipselink.target-database" value="Oracle11"/>
</properties>
</persistence-unit>
</persistence>