mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
50 lines
1.1 KiB
Java
50 lines
1.1 KiB
Java
package io.ebeaninternal.server.query;
|
|
|
|
import io.ebeaninternal.api.CQueryPlanKey;
|
|
|
|
/**
|
|
* QueryPlanKey for native sql queries.
|
|
*/
|
|
public class NativeSqlQueryPlanKey implements CQueryPlanKey {
|
|
|
|
private final String sql;
|
|
|
|
public NativeSqlQueryPlanKey(String sql) {
|
|
this.sql = sql;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return getPartialKey();
|
|
}
|
|
|
|
@Override
|
|
public CQueryPlanKey withDeleteByIds() {
|
|
throw new IllegalStateException("Not allowed");
|
|
}
|
|
|
|
/**
|
|
* Return as a partial key. For rawSql hash the sql is part of the key and as such
|
|
* needs to be included in order to have a complete key. Typically the MD5 of the sql
|
|
* can be used as a short form proxy for the actual sql.
|
|
*/
|
|
@Override
|
|
public String getPartialKey() {
|
|
return hashCode() + "_n";
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) return true;
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
NativeSqlQueryPlanKey that = (NativeSqlQueryPlanKey) o;
|
|
return sql.equals(that.sql);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return sql.hashCode();
|
|
}
|
|
}
|