The following JPQL query:
SELECT e.id.identity, e.id.type, e.id.created FROM Event e
gets translated into the following CQL:
SELECT "identity","type","created" FROM "events" LIMIT 100
But the returned List contains Event objects instead of arrays of Object
List<Object[]> list = query.getResultList();
The list is returned as a list of Event objects.
Another JPQL query that tries to get the whole key as an Object:
SELECT e.id FROM Event e
gets translated into the following CQL:
SELECT "id" FROM "events" LIMIT 100
and obviously fails because "id" is a compound/EmbeddedId field.
Here is the definition of the entity and the embedded class.
@Entity
@Table(name = "events")
@Inheritance(strategy = javax.persistence.InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "typed")
public class Event implements java.io.Serializable {
@EmbeddedId
@OrderBy("id.type ASC, id.created DESC")
private EventId id;
public EventId getId() {
return id;
}
public void setId(final EventId value) {
id = value;
}
}
@Embeddable
public class EventId implements java.io.Serializable {
@Column
private java.util.UUID identity = null;
public java.util.UUID getIdentity() {
return identity;
}
public void setIdentity(final java.util.UUID value) {
identity = value;
}
@Column
private String type = null;
public String getType() {
return type;
}
public void setType(final String value) {
type = value;
}
@Column
private java.util.UUID created = null;
public java.util.UUID getCreated() {
return created;
}
public void setCreated(final java.util.UUID value) {
created = value;
}
}
Thanks.
The following JPQL query:
SELECT e.id.identity, e.id.type, e.id.created FROM Event egets translated into the following CQL:
SELECT "identity","type","created" FROM "events" LIMIT 100But the returned List contains Event objects instead of arrays of Object
List<Object[]> list = query.getResultList();
The list is returned as a list of Event objects.
Another JPQL query that tries to get the whole key as an Object:
SELECT e.id FROM Event egets translated into the following CQL:
SELECT "id" FROM "events" LIMIT 100and obviously fails because "id" is a compound/EmbeddedId field.
Here is the definition of the entity and the embedded class.
Thanks.