Author: stliu
Date: 2010-01-01 12:32:13 -0500 (Fri, 01 Jan 2010)
New Revision: 18377
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/ThingServiceBean.java
sandbox/trunk/lobtest-ee5/lobtest-web/src/main/webapp/basic.jsp
Log:
ignore the metadata files generated by eclipse, move profiles from sub-module to the top
pom.xml
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 2010-01-01
17:27:49 UTC (rev 18376)
+++
sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/java/com/redhat/gss/lobtest/ejb/ThingService.java 2010-01-01
17:32:13 UTC (rev 18377)
@@ -12,13 +12,13 @@
public Thing findThingHibernate(Long id);
- public List<Thing> findAllThingsJPA();
-
- public Thing findThingJPA(Long id);
-
- public Thing findThingJPAjndi(Long id) throws Exception;
-
- public Thing findThingHibernateMBean(Long id) throws Exception;
-
- public Thing findThingJPAThruHibernate(Long id);
+// public List<Thing> findAllThingsJPA();
+//
+// 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 2010-01-01
17:27:49 UTC (rev 18376)
+++
sandbox/trunk/lobtest-ee5/lobtest-ejb/src/main/java/com/redhat/gss/lobtest/ejb/ThingServiceBean.java 2010-01-01
17:32:13 UTC (rev 18377)
@@ -2,6 +2,7 @@
import java.util.List;
+import javax.ejb.Stateful;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@@ -14,53 +15,21 @@
import com.redhat.gss.lobtest.hibernate.HibernateUtil;
import com.redhat.gss.lobtest.jpa.Thing;
-@Stateless
+@Stateful
public class ThingServiceBean implements ThingService
{
- @PersistenceContext(unitName="lobtest-jpa")
- private EntityManager em;
+
@SuppressWarnings("unchecked")
public List<Thing> findAllThingsHibernate()
{
Session s = HibernateUtil.getSession();
return s.createQuery("from Thing").list();
}
-
- @SuppressWarnings("unchecked")
- public List<Thing> findAllThingsJPA()
- {
- 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)
{
@@ -72,24 +41,26 @@
}
// 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/LobTestSessionFactory");
- s = sf.getCurrentSession();
+// public Thing findThingHibernateMBean(Long id) throws Exception
+// {
+// Thing t = null;
+// Session s = null;
+// InitialContext ctx = new InitialContext();
+// SessionFactory sf = (SessionFactory)
ctx.lookup("java:/hibernate/LobTestSessionFactory");
+// s = sf.getCurrentSession();
+//
+// t = (Thing) s.load(Thing.class, id);
+// System.out.println("Thing: id=" + t.getId() + " name=" +
t.getName() + " class=" + t.getClass());
+// return t;
+// }
- t = (Thing) s.load(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");
- em.persist(t1);
+ Session s= HibernateUtil.getSession();
+ s.persist( t1 );
+ //em.persist(t1);
return t1;
}
Modified: sandbox/trunk/lobtest-ee5/lobtest-web/src/main/webapp/basic.jsp
===================================================================
--- sandbox/trunk/lobtest-ee5/lobtest-web/src/main/webapp/basic.jsp 2010-01-01 17:27:49
UTC (rev 18376)
+++ sandbox/trunk/lobtest-ee5/lobtest-web/src/main/webapp/basic.jsp 2010-01-01 17:32:13
UTC (rev 18377)
@@ -14,35 +14,15 @@
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("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("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.
Show replies by date