[jboss-svn-commits] JBL Code SVN: r5219 - in labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl: . protocol/db
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jul 21 11:56:34 EDT 2006
Author: wrzep
Date: 2006-07-21 11:56:31 -0400 (Fri, 21 Jul 2006)
New Revision: 5219
Modified:
labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/DBServiceImpl.java
labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/db/PluginValuesEntity.java
labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/db/PluginsValuesEntity.java
Log:
JBLAB-689
Back to lazy fetch type.
Used JOIN FETCH instead.
Pawel
Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/DBServiceImpl.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/DBServiceImpl.java 2006-07-21 13:30:47 UTC (rev 5218)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/DBServiceImpl.java 2006-07-21 15:56:31 UTC (rev 5219)
@@ -23,17 +23,20 @@
package org.jboss.forge.status.service.impl;
import java.util.Calendar;
+import java.util.List;
import javax.ejb.Local;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import static javax.persistence.PersistenceContextType.EXTENDED;
+
import org.jboss.annotation.ejb.LocalBinding;
import org.jboss.forge.status.common.Constants;
import org.jboss.forge.status.service.DBService;
-import org.jboss.forge.status.service.impl.protocol.db.PluginsValuesEntity;
import org.jboss.forge.status.service.protocol.PluginsValues;
@@ -46,7 +49,7 @@
@LocalBinding(jndiBinding=Constants.DB_SERVICE)
public class DBServiceImpl implements DBService {
- @PersistenceContext (unitName="scores")
+ @PersistenceContext (unitName="scores", type=EXTENDED)
protected EntityManager em;
public void init() {}
@@ -58,9 +61,13 @@
public PluginsValues get(Calendar date) {
- PluginsValues pv = em.find(PluginsValuesEntity.class, Long.valueOf(1));
+ Query query = em.createQuery(
+ "SELECT c FROM PluginsValuesEntity c LEFT JOIN FETCH c.v");
+ List list = query.getResultList();
- return pv;
+ System.out.println("get(0): " + list.get(0));
+
+ return (PluginsValues) list.get(0);
}
}
Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/db/PluginValuesEntity.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/db/PluginValuesEntity.java 2006-07-21 13:30:47 UTC (rev 5218)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/db/PluginValuesEntity.java 2006-07-21 15:56:31 UTC (rev 5219)
@@ -30,12 +30,13 @@
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.MapKey;
import javax.persistence.OneToMany;
+import javax.persistence.PostLoad;
+import javax.persistence.PreUpdate;
import javax.persistence.Table;
import org.jboss.forge.status.plugins.Plugin;
@@ -108,7 +109,7 @@
this.linkName = linkName;
}
- @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
+ @OneToMany(cascade={CascadeType.ALL})
@JoinColumn(name="plugin_values_id")
@MapKey(name="projectId")
public Map<String, ValueEntity> getValues() {
Modified: labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/db/PluginsValuesEntity.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/db/PluginsValuesEntity.java 2006-07-21 13:30:47 UTC (rev 5218)
+++ labs/jbosslabs/trunk/portal-extensions/forge-status/src/java/org/jboss/forge/status/service/impl/protocol/db/PluginsValuesEntity.java 2006-07-21 15:56:31 UTC (rev 5219)
@@ -24,6 +24,7 @@
package org.jboss.forge.status.service.impl.protocol.db;
import java.util.Calendar;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -37,6 +38,8 @@
import javax.persistence.JoinColumn;
import javax.persistence.MapKey;
import javax.persistence.OneToMany;
+import javax.persistence.PostLoad;
+import javax.persistence.PreUpdate;
import javax.persistence.Table;
import org.jboss.forge.common.projects.Projects;
@@ -65,12 +68,13 @@
/** Map : pluginId -> pluginValue */
private Map<String,PluginValuesEntity> values;
-
+
+ private Collection<PluginValuesEntity> v;
+
/**
* Default constructor
*/
public PluginsValuesEntity () {}
-
/**
* @param projects Projects present in the Status Matrix
@@ -114,8 +118,18 @@
this.date = date;
}
- @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
+ @OneToMany(cascade={CascadeType.ALL})
@JoinColumn(name="plugins_values_id")
+ public Collection<PluginValuesEntity> getV() {
+ return v;
+ }
+
+ public void setV(Collection<PluginValuesEntity> v) {
+ this.v = v;
+ }
+
+ @OneToMany(cascade={CascadeType.ALL})
+ @JoinColumn(name="plugins_values_id")
@MapKey(name="pluginId")
public Map<String, PluginValuesEntity> getValues() {
return values;
More information about the jboss-svn-commits
mailing list