Basically, I have a named query "findServerWithNic" that refuses to work:
@Entity
@Table(name = "vnm_server")
@DiscriminatorValue("S")
@NamedQueries({
@NamedQuery(
name="findServerWithNic",
query="SELECT s FROM Server s, Nic n "+
"WHERE n.id = :nicId AND n member of s.nics"
)
})
public class Server extends NetworkedDevice implements Serializable
{...}
nics is not defined on the server, but in it is a superclass of NetworkedDevice:
@Entity
@Table(name = "vnm_networked_device")
@DiscriminatorColumn(name = "c_device_type", discriminatorType = DiscriminatorType.CHAR)
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class NetworkedDevice extends AbstractIdentifyable implements Serializable
{
@OneToMany(mappedBy = "connectedHost", cascade = CascadeType.ALL)
@OrderColumn(name = "c_index")
protected List<Nic> nics = new ArrayList<Nic>();
public List<Nic> getNics() {
return nics;
}
public void setNics(List<Nic> nics) {
this.nics = nics;
}
}
now I have a test file that creates Nic instances, adds it to the server instance (s.getNics () contains the instance, I checked), but the request is called
public Server findVirtualServerOfNic(Long nicId) {
final Server network = em.createNamedQuery("findServerWithNic", Server.class)
.setParameter("nicId", nicId)
.getSingleResult();
return network;
}
throws NoResultException
Caused by: javax.persistence.NoResultException: getSingleResult() did not retrieve any entities.
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.throwNoResultException(EJBQueryImpl.java:1246)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:750)
at com.profitbricks.provisioning.vnm.jpa.impl.VNManagementJPAImpl.findVirtualServerOfNic(VNManagementJPAImpl.java:101)
initially the nics member was closed, but even setting it up for protection did not work. We use eclipselink 2.2.0-M4 as our JPA 2 provider. Is this an eclipselink error or is the request incorrect?
source
share