[hibernate-commits] Hibernate SVN: r17691 - in sandbox/trunk/lobtest-ee5: lobtest-ear/src/main/application/META-INF and 5 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Mon Oct 12 02:20:12 EDT 2009
Author: dstephan
Date: 2009-10-12 02:20:12 -0400 (Mon, 12 Oct 2009)
New Revision: 17691
Added:
sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/resources/hibernate.properties
Removed:
sandbox/trunk/lobtest-ee5/lobtest-ear/src/main/application/META-INF/application.xml
Modified:
sandbox/trunk/lobtest-ee5/lobtest-ear/pom.xml
sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/java/com/redhat/gss/lobtest/ejb/LobTestServiceBean.java
sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/java/com/redhat/gss/lobtest/ejb/ThingService.java
sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/java/com/redhat/gss/lobtest/ejb/ThingServiceBean.java
sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/resources/META-INF/persistence.xml
sandbox/trunk/lobtest-ee5/lobtest-sar/src/main/resources/META-INF/jboss-service.xml
sandbox/trunk/lobtest-ee5/lobtest-web/src/main/webapp/basic.jsp
Log:
Updated to include deployment and tests for additional use cases.
Modified: sandbox/trunk/lobtest-ee5/lobtest-ear/pom.xml
===================================================================
--- sandbox/trunk/lobtest-ee5/lobtest-ear/pom.xml 2009-10-12 02:53:54 UTC (rev 17690)
+++ sandbox/trunk/lobtest-ee5/lobtest-ear/pom.xml 2009-10-12 06:20:12 UTC (rev 17691)
@@ -31,7 +31,7 @@
<artifactId>lobtest-web</artifactId>
</webModule>
</modules>
- <applicationXml>${project.build.directory}/application.xml</applicationXml>
+ <!-- <applicationXml>${project.build.directory}/application.xml</applicationXml> -->
</configuration>
</plugin>
</plugins>
Deleted: sandbox/trunk/lobtest-ee5/lobtest-ear/src/main/application/META-INF/application.xml
===================================================================
--- sandbox/trunk/lobtest-ee5/lobtest-ear/src/main/application/META-INF/application.xml 2009-10-12 02:53:54 UTC (rev 17690)
+++ sandbox/trunk/lobtest-ee5/lobtest-ear/src/main/application/META-INF/application.xml 2009-10-12 06:20:12 UTC (rev 17691)
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
-<application id="Application_ID">
- <display-name>lobtest-ear</display-name>
- <module id="EjbModule_1255048702485">
- <ejb>lobtest-ejb-1.0-SNAPSHOT.jar</ejb>
- </module>
- <module id="WebModule_1255048702585">
- <web>
- <web-uri>lobtest-web.war</web-uri>
- <context-root>lobtest-web</context-root>
- </web>
- </module>
-</application>
Modified: sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/java/com/redhat/gss/lobtest/ejb/LobTestServiceBean.java
===================================================================
--- sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/java/com/redhat/gss/lobtest/ejb/LobTestServiceBean.java 2009-10-12 02:53:54 UTC (rev 17690)
+++ sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/java/com/redhat/gss/lobtest/ejb/LobTestServiceBean.java 2009-10-12 06:20:12 UTC (rev 17691)
@@ -24,7 +24,7 @@
private static final String DESCRIPTION = "Long description requiring more space than I have time to consume.";
private static final byte[] IMAGE_DATA = { 'E', 'A', 'D', 'G', 'B', 'E' };
- @PersistenceContext//(name="lobtest-jpa")
+ @PersistenceContext(unitName="lobtest-jpa")//(name="lobtest-jpa")
private EntityManager em;
public void runTests() {
Modified: sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/java/com/redhat/gss/lobtest/ejb/ThingService.java
===================================================================
--- sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/java/com/redhat/gss/lobtest/ejb/ThingService.java 2009-10-12 02:53:54 UTC (rev 17690)
+++ sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/java/com/redhat/gss/lobtest/ejb/ThingService.java 2009-10-12 06:20:12 UTC (rev 17691)
@@ -16,5 +16,9 @@
public Thing findThingJPA(Long id);
+ public Thing findThingJPAjndi(Long id) throws Exception;
+
public Thing findThingHibernateMBean(Long id) throws Exception;
+
+ public Thing findThingJPAThruHibernate(Long id);
}
Modified: sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/java/com/redhat/gss/lobtest/ejb/ThingServiceBean.java
===================================================================
--- sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/java/com/redhat/gss/lobtest/ejb/ThingServiceBean.java 2009-10-12 02:53:54 UTC (rev 17690)
+++ sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/java/com/redhat/gss/lobtest/ejb/ThingServiceBean.java 2009-10-12 06:20:12 UTC (rev 17691)
@@ -18,7 +18,7 @@
public class ThingServiceBean implements ThingService
{
- @PersistenceContext
+ @PersistenceContext(unitName="lobtest-jpa")
private EntityManager em;
@SuppressWarnings("unchecked")
@@ -34,6 +34,34 @@
return em.createQuery("from Thing").getResultList();
}
+ // Use Cae A-1
+ public Thing findThingJPA(Long id)
+ {
+ Thing t = em.getReference(Thing.class, id);
+ System.out.println("Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
+ return t;
+ }
+
+ //Use Case A-2
+ public Thing findThingJPAjndi(Long id) throws Exception
+ {
+ InitialContext ctx = new InitialContext();
+ EntityManager em = (EntityManager) ctx.lookup("persistence/EntityManager");
+ Thing t = em.getReference(Thing.class, id);
+ System.out.println("Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
+ return t;
+ }
+
+ //Use Case A-3
+ public Thing findThingJPAThruHibernate(Long id)
+ {
+ Session s = (Session)em.getDelegate();
+ Thing t = (Thing) s.load(Thing.class, id);
+ System.out.println("Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
+ return t;
+ }
+
+ // Use Case B-1
public Thing findThingHibernate(Long id)
{
Session s = HibernateUtil.getSession();
@@ -43,12 +71,13 @@
return t;
}
+ // Use Case B-2
public Thing findThingHibernateMBean(Long id) throws Exception
{
Thing t = null;
Session s = null;
InitialContext ctx = new InitialContext();
- SessionFactory sf = (SessionFactory) ctx.lookup("java:hibernate/SessionFactory");
+ SessionFactory sf = (SessionFactory) ctx.lookup("java:/hibernate/LobTestSessionFactory");
s = sf.getCurrentSession();
t = (Thing) s.load(Thing.class, id);
@@ -56,13 +85,7 @@
return t;
}
- public Thing findThingJPA(Long id)
- {
- Thing t = em.getReference(Thing.class, id);
- System.out.println("Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
- return t;
- }
-
+
public Thing setUp()
{
Thing t1 = new Thing(System.currentTimeMillis(), "One");
Modified: sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/resources/META-INF/persistence.xml
===================================================================
--- sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/resources/META-INF/persistence.xml 2009-10-12 02:53:54 UTC (rev 17690)
+++ sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/resources/META-INF/persistence.xml 2009-10-12 06:20:12 UTC (rev 17691)
@@ -7,6 +7,16 @@
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <!-- <property name="hibernate.bytecode.provide" value="javassist"/>-->
</properties>
</persistence-unit>
+ <persistence-unit name="lobtest-jpa-jndi">
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ <properties>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+ <property name="jboss.entity.manager.factory.jndi.name"
+ value="persistence/EntityManagerFactory" />
+ <property name="jboss.entity.manager.jndi.name" value="persistence/EntityManager"/>
+ </properties>
+ </persistence-unit>
</persistence>
\ No newline at end of file
Added: sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/resources/hibernate.properties
===================================================================
--- sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/resources/hibernate.properties (rev 0)
+++ sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/resources/hibernate.properties 2009-10-12 06:20:12 UTC (rev 17691)
@@ -0,0 +1 @@
+#hibernate.bytecode.provider=cglib
\ No newline at end of file
Modified: sandbox/trunk/lobtest-ee5/lobtest-sar/src/main/resources/META-INF/jboss-service.xml
===================================================================
--- sandbox/trunk/lobtest-ee5/lobtest-sar/src/main/resources/META-INF/jboss-service.xml 2009-10-12 02:53:54 UTC (rev 17690)
+++ sandbox/trunk/lobtest-ee5/lobtest-sar/src/main/resources/META-INF/jboss-service.xml 2009-10-12 06:20:12 UTC (rev 17691)
@@ -1,13 +1,13 @@
<?xml version="1.0"?>
<server>
- <mbean code="org.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory,name=HibernateFactory">
+ <mbean code="org.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory,name=LobTestHibernateFactory">
- <depends>jboss.jca:service=RARDeployer</depends>
+ <!-- <depends>jboss.jca:service=RARDeployer</depends>-->
<depends>jboss.jca:service=LocalTxCM,name=DefaultDS</depends>
<!-- Bind the Hibernate service to JNDI -->
- <attribute name="JndiName">java:/hibernate/SessionFactory</attribute>
+ <attribute name="JndiName">java:/hibernate/LobTestSessionFactory</attribute>
<!-- hibernate dialect -->
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
Modified: sandbox/trunk/lobtest-ee5/lobtest-web/src/main/webapp/basic.jsp
===================================================================
--- sandbox/trunk/lobtest-ee5/lobtest-web/src/main/webapp/basic.jsp 2009-10-12 02:53:54 UTC (rev 17690)
+++ sandbox/trunk/lobtest-ee5/lobtest-web/src/main/webapp/basic.jsp 2009-10-12 06:20:12 UTC (rev 17691)
@@ -14,13 +14,35 @@
System.out.println("basic.jsp from query: Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
}
+ t = ts.findThingJPA(t.getId());
+ System.out.println("A-1 - basic.jsp from ts.findThingJPA(): Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
+ out.println("A-1 - basic.jsp from ts.findThingJPA(): Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
+ %>
+ </br>
+ <%
+ t = ts.findThingJPAjndi(t.getId());
+ System.out.println("A-2 - basic.jsp from ts.findJPAjndi(): Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
+ out.println("A-2 - basic.jsp from ts.findJPAjndi(): Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
+ %>
+ </br>
+ <%
+ t = ts.findThingJPAThruHibernate(t.getId());
+ System.out.println("A-3 - basic.jsp from ts.findThingJPAThruHibernate(): Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
+ out.println("A-3 - basic.jsp from ts.findThingJPAThruHibernate(): Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
+ %>
+ </br>
+ <%
t = ts.findThingHibernate(t.getId());
- System.out.println("basic.jsp from ts.findThingHibernate(): Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
-
- t = ts.findThingJPA(t.getId());
- System.out.println("basic.jsp from ts.findThingJPA(): Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
-
+ System.out.println("B-1 - basic.jsp from ts.findThingHibernate(): Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
+ out.println("B-1 - basic.jsp from ts.findThingHibernate(): Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
+ %>
+ </br>
+ <%
t = ts.findThingHibernateMBean(t.getId());
- System.out.println("basic.jsp from ts.findThingHibernateMBean(): Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
+ System.out.println("B-2 - basic.jsp from ts.findThingHibernateMBean(): Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
+ out.println("B-2 - basic.jsp from ts.findThingHibernateMBean(): Thing: id=" + t.getId() + " name=" + t.getName() + " class=" + t.getClass());
+
+
%>
+</br>
Tests run successfully.
More information about the hibernate-commits
mailing list