mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#345 - Expose Query.getId() and Query.getBeanType() methods ... (previously on SpiQuery)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user