The following named query "findAllRealWithVehicle" fails to fetch all RealRun objects and returns only some.
RealRun.java: import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery;
import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy;
@Entity() @DiscriminatorValue(value="0") @NamedQueries(value = { @NamedQuery(name = "findAllRealWithVehicle", query = "SELECT OBJECT(r) " + "FROM RealRun r JOIN FETCH r.physicalVehicle " + "WHERE r.deletionTimestamp IS NULL ORDER BY r.publicId") }
) @Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL) public class RealRun extends Run { }
Run.java: import javax.persistence.Column; import javax.persistence.DiscriminatorColumn; import javax.persistence.DiscriminatorType; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType;
import org.apache.log4j.Logger; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.GenericGenerator;
@Entity() @Table(name="k3_vehicle") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "virtual_vehicle", discriminatorType = DiscriminatorType.INTEGER, columnDefinition="bit") @Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL) public abstract class Run { private String publicId; private Date deletionTimestamp; private PhysicalVehicle physicalVehicle;
/**
-
Time of deletion.
*/ @Temporal(TemporalType.TIMESTAMP) @Column(name = "deletion_timestamp") public Date getDeletionTimestamp() { return deletionTimestamp; }
public void setDeletionTimestamp(Date deletionTimestamp) { this.deletionTimestamp = deletionTimestamp; }
@Override @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="physical_vehicle_fk") @Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL) public PhysicalVehicle getPhysicalVehicle() { return physicalVehicle; }
public void setPhysicalVehicle(PhysicalVehicle physicalVehicle) { this.physicalVehicle = physicalVehicle; }
@Override @Column(name = "publicId") public String getPublicId() { return publicId; }
public void setPublicId(String publicId) { this.publicId = publicId; }
}
PhysicalVehicle.java:
import javax.persistence.Entity; import javax.persistence.Table;
import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy;
@Entity @Table(name="k3_physical_vehicle") @Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL) public class PhysicalVehicle { }
|