#345 - Expose Query.getId() and Query.getBeanType() methods ... (previously on SpiQuery)

This commit is contained in:
Robin Bygrave
2015-07-20 12:24:56 +12:00
parent 1a6f68edd3
commit f45d240682
3 changed files with 15 additions and 15 deletions
+11
View File
@@ -866,6 +866,11 @@ public interface Query<T> extends Serializable {
*/
Query<T> setId(Object id);
/**
* Return the Id value.
*/
Object getId();
/**
* Add additional clause(s) to the where clause.
* <p>
@@ -1223,4 +1228,10 @@ public interface Query<T> extends Serializable {
* Set root table alias.
*/
Query<T> alias(String alias);
/**
* Return the type of beans being queried.
*/
Class<T> getBeanType();
}
@@ -481,11 +481,6 @@ public interface SpiQuery<T> extends Query<T> {
*/
void contextAdd(EntityBean bean);
/**
* Return the type of beans queries.
*/
Class<T> getBeanType();
/**
* Return the query timeout.
*/
@@ -580,11 +575,6 @@ public interface SpiQuery<T> extends Query<T> {
*/
String getRawWhereClause();
/**
* Return the Id value.
*/
Object getId();
/**
* Set the generated sql for debug purposes.
*/
@@ -1163,16 +1163,15 @@ public final class DefaultServer implements SpiEbeanServer {
public <T> T findUnique(Query<T> query, Transaction t) {
// actually a find by Id type of query...
// ... perhaps with joins and cache hints?
SpiQuery<T> q = (SpiQuery<T>) query;
Object id = q.getId();
// ... perhaps with joins and cache hints
Object id = query.getId();
if (id != null) {
return findId(query, t);
}
BeanDescriptor<T> desc = beanDescriptorManager.getBeanDescriptor(q.getBeanType());
BeanDescriptor<T> desc = beanDescriptorManager.getBeanDescriptor(query.getBeanType());
T bean = desc.cacheNaturalKeyLookup(q, (SpiTransaction) t);
T bean = desc.cacheNaturalKeyLookup((SpiQuery<T>)query, (SpiTransaction) t);
if (bean != null) {
return bean;
}