From: Erik Brakkee Date: Tue, 12 Feb 2008 21:00:03 +0000 (+0000) Subject: now using JPA annotations. X-Git-Tag: wamblee-utils-0.7~853 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=244c2406bd9ae23fd4d8dfb07eda03e8bcf95bb3;hp=056829b24467d75bd891ba1079f7d6c1f6b75221;p=utils now using JPA annotations. --- diff --git a/mythtv/ear/pom.xml b/mythtv/ear/pom.xml index 81746141..a1e1aa80 100644 --- a/mythtv/ear/pom.xml +++ b/mythtv/ear/pom.xml @@ -33,6 +33,10 @@ ${project.version} ejb + + org.hibernate + hibernate-entitymanager + diff --git a/mythtv/monitor/pom.xml b/mythtv/monitor/pom.xml index 52333044..9c031a2f 100644 --- a/mythtv/monitor/pom.xml +++ b/mythtv/monitor/pom.xml @@ -24,6 +24,10 @@ javax.servlet servlet-api + + javax.persistence + persistence-api + log4j log4j diff --git a/mythtv/monitor/src/main/java/org/wamblee/mythtv/Channel.java b/mythtv/monitor/src/main/java/org/wamblee/mythtv/Channel.java index 104e3aac..e5ef7047 100644 --- a/mythtv/monitor/src/main/java/org/wamblee/mythtv/Channel.java +++ b/mythtv/monitor/src/main/java/org/wamblee/mythtv/Channel.java @@ -16,13 +16,23 @@ package org.wamblee.mythtv; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + /** * */ +@Entity +@Table(name="channel") public class Channel { + @Id + @Column(name="chanid") private int _id; + @Column(name="name") private String _name; protected Channel() { diff --git a/mythtv/monitor/src/main/java/org/wamblee/mythtv/Recording.java b/mythtv/monitor/src/main/java/org/wamblee/mythtv/Recording.java index cab43a6b..ca0ab1cb 100644 --- a/mythtv/monitor/src/main/java/org/wamblee/mythtv/Recording.java +++ b/mythtv/monitor/src/main/java/org/wamblee/mythtv/Recording.java @@ -19,23 +19,44 @@ package org.wamblee.mythtv; import java.io.Serializable; import java.util.Date; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + /** * */ +@Entity +@Table(name="recorded") +//@IdClass(RecordingPk.class) public class Recording implements Serializable { + //@Id + @ManyToOne(targetEntity=Channel.class) + @JoinColumn(name="chanid") private Channel _channel; + @Id + @Column(name="starttime") private Date _starttime; - + @Column(name="basename") private String _basename; + @Column(name="progstart") private Date _progstart; - + + @Column(name="title") private String _title; + @Column(name="subtitle") private String _subtitle; + @Column(name="filesize") private long _filesize; protected Recording() { diff --git a/mythtv/timer/src/main/java/org/wamblee/timer/TimerBean.java b/mythtv/timer/src/main/java/org/wamblee/timer/TimerBean.java index 45e6e220..ca910301 100644 --- a/mythtv/timer/src/main/java/org/wamblee/timer/TimerBean.java +++ b/mythtv/timer/src/main/java/org/wamblee/timer/TimerBean.java @@ -21,6 +21,10 @@ import javax.ejb.MessageDriven; import javax.ejb.Timeout; import javax.ejb.Timer; import javax.ejb.TimerService; +import javax.ejb.TransactionAttribute; +import javax.ejb.TransactionAttributeType; +import javax.ejb.TransactionManagement; +import javax.ejb.TransactionManagementType; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; @@ -36,6 +40,9 @@ import org.wamblee.io.DirectoryMonitor; * */ @MessageDriven(name = "MythtvTimer") +// Spring's JTA transaction manager does not work with container managed transactions +// because it uses the UserTransaction object which glassfish forbids. +@TransactionManagement(TransactionManagementType.BEAN) public class TimerBean implements MessageListener { private static final Log LOG = LogFactory.getLog(TimerBean.class); diff --git a/mythtv/war/src/main/resources/beanRefContext.xml b/mythtv/war/src/main/resources/beanRefContext.xml index fff0f4c3..5288aba3 100644 --- a/mythtv/war/src/main/resources/beanRefContext.xml +++ b/mythtv/war/src/main/resources/beanRefContext.xml @@ -9,7 +9,6 @@ org.wamblee.mythtv.properties.xml org.wamblee.mythtv.datasource.xml - org.wamblee.mythtv.hibernatemappings.xml org.wamblee.mythtv.hibernate.xml org.wamblee.mythtv.application.xml diff --git a/mythtv/war/src/main/resources/org.wamblee.mythtv.application.xml b/mythtv/war/src/main/resources/org.wamblee.mythtv.application.xml index 1017fffa..1a8d0106 100644 --- a/mythtv/war/src/main/resources/org.wamblee.mythtv.application.xml +++ b/mythtv/war/src/main/resources/org.wamblee.mythtv.application.xml @@ -2,39 +2,66 @@ - + - ${org.wamblee.mythtv.linkdir} + + ${org.wamblee.mythtv.linkdir} + - + - ${org.wamblee.mythtv.monitordir} + + ${org.wamblee.mythtv.monitordir} + - + - ^[a-zA-Z0-9-_]*.mpg$ + + ^[a-zA-Z0-9-_]*.mpg$ + - - + + - + init-method="init"> + + + - - - ${org.wamblee.mythtv.monitordir} - - + + + + + + ${org.wamblee.mythtv.monitordir} + + + + + + + + + - + - - - + + + + + + + + + - + - ${org.wamblee.mythtv.pollinterval} + + ${org.wamblee.mythtv.pollinterval} + - + diff --git a/mythtv/war/src/main/resources/org.wamblee.mythtv.hibernate.xml b/mythtv/war/src/main/resources/org.wamblee.mythtv.hibernate.xml index 4d34ac8d..03a664af 100644 --- a/mythtv/war/src/main/resources/org.wamblee.mythtv.hibernate.xml +++ b/mythtv/war/src/main/resources/org.wamblee.mythtv.hibernate.xml @@ -5,7 +5,7 @@ - + @@ -19,8 +19,11 @@ - - + + + org.wamblee.mythtv.Channel + org.wamblee.mythtv.Recording + + + +