fixed bug with LAZY fetch of ElementCollections

This commit is contained in:
Walter Oggioni
2017-07-14 23:39:08 +02:00
parent 7bae3c9d14
commit f6b4ae3c71
5 changed files with 38 additions and 30 deletions

View File

@@ -4,6 +4,7 @@ import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;
import java.util.List;
import java.util.Set;
/**
* Created by walter on 22/03/15.
@@ -12,8 +13,8 @@ import java.util.List;
@Entity
@XmlRootElement
@NamedQuery(name="searchById", query = "SELECT p FROM PkgData p WHERE p.id = :id")
@Table(indexes = { @Index(columnList = "md5sum", unique = true), @Index(columnList = "fileName", unique = true) })
@NamedQuery(name = "searchById", query = "SELECT p FROM PkgData p WHERE p.id = :id")
@Table(indexes = {@Index(columnList = "md5sum", unique = true), @Index(columnList = "fileName", unique = true)})
public class PkgData
{
@Id
@@ -46,29 +47,29 @@ public class PkgData
public String fileName;
@ElementCollection(fetch = FetchType.LAZY)
public List<String> replaces;
@ElementCollection(fetch = FetchType.EAGER)
public Set<String> replaces;
@ElementCollection(fetch = FetchType.LAZY)
public List<String> conflict;
@ElementCollection(fetch = FetchType.EAGER)
public Set<String> conflict;
@ElementCollection(fetch = FetchType.LAZY)
public List<String> provides;
@ElementCollection(fetch = FetchType.EAGER)
public Set<String> provides;
@ElementCollection(fetch = FetchType.LAZY)
public List<String> depend;
@ElementCollection(fetch = FetchType.EAGER)
public Set<String> depend;
@ElementCollection(fetch = FetchType.LAZY)
public List<String> optdepend;
@ElementCollection(fetch = FetchType.EAGER)
public Set<String> optdepend;
@ElementCollection(fetch = FetchType.LAZY)
public List<String> makedepend;
@ElementCollection(fetch = FetchType.EAGER)
public Set<String> makedepend;
@ElementCollection(fetch = FetchType.LAZY)
public List<String> makeopkgopt;
@ElementCollection(fetch = FetchType.EAGER)
public Set<String> makeopkgopt;
@ElementCollection(fetch = FetchType.LAZY)
public List<String> backup;
@ElementCollection(fetch = FetchType.EAGER)
public Set<String> backup;
@Temporal(TemporalType.TIMESTAMP)
public Date updTimestamp;

View File

@@ -78,7 +78,7 @@ public class Parser
data.arch = propMap.get(key).get(0);
break;
case "replaces":
data.replaces = propMap.get(key);
data.replaces = new HashSet(propMap.get(key));
break;
case "packager":
data.packager = propMap.get(key).get(0);
@@ -102,25 +102,25 @@ public class Parser
data.description = propMap.get(key).get(0);
break;
case "provides":
data.provides = propMap.get(key);
data.provides = new HashSet(propMap.get(key));
break;
case "conflict":
data.conflict = propMap.get(key);
data.conflict = new HashSet(propMap.get(key));
break;
case "backup":
data.backup = propMap.get(key);
data.backup = new HashSet(propMap.get(key));
break;
case "optdepend":
data.optdepend = propMap.get(key);
data.optdepend = new HashSet(propMap.get(key));
break;
case "depend":
data.depend = propMap.get(key);
data.depend = new HashSet(propMap.get(key));
break;
case "makedepend":
data.makedepend = propMap.get(key);
data.makedepend = new HashSet(propMap.get(key));
break;
case "makepkgopt":
data.makeopkgopt = propMap.get(key);
data.makeopkgopt = new HashSet(propMap.get(key));
break;
case "pkgbase":
data.base = propMap.get(key).get(0);

View File

@@ -73,6 +73,7 @@ public class PacmanWebService
}
else if (name != null || arch != null || version != null)
{
QueryEngine qe = new QueryEngine(PkgData.class);
qe.select();
if (name != null) qe.where("name", "=", name);