18 package org.turro.elephant.db;
20 import java.util.logging.Level;
21 import java.util.logging.Logger;
22 import org.turro.string.Strings;
23 import org.turro.elephant.context.ElephantContext;
24 import org.turro.elephant.impl.util.StringParser;
25 import org.turro.jpa.Dao;
41 wc.
addClause(
"select max(a." + field +
") + 1 from " + table +
" a");
42 wc.
addClause(
"where a." + field +
" = (");
43 wc.
addClause(
" select count(*) from " + table +
" b");
46 for(String fc : fieldConstraints) {
50 for(String fc : fieldConstraints) {
54 if(result ==
null || result == 0) {
68 wc.
addClause(
"select max(cast(a." + field +
" as signed)) + 1 from " + table +
" a");
70 wc.
addClause(
" select count(*) from " + table +
" b");
73 for(String fc : fieldConstraints) {
77 for(String fc : fieldConstraints) {
81 if(result ==
null || result == 0) {
85 }
catch(Exception ex) {
101 wc.
addClause(
"select count(a." + field +
"), max(a." + field +
") from " + table +
" a");
103 for(String fc : fieldConstraints) {
107 Long regs = (Long) result[0],
id = (Long) result[1];
108 if(
id ==
null ||
id == 0) {
112 return count ? (regs.equals(
id) ?
id + 1L : 0L) :
id + 1L;
122 wc.
addClause(
"select max(cast(a." + field +
" as signed)) from " + table +
" a");
124 for(String fc : fieldConstraints) {
128 if(result ==
null || result == 0) {
129 result = Long.valueOf(0);
132 }
catch(Exception ex) {
138 public static String
putPrefix(String field, String prefix) {
139 int p = Math.max(field.lastIndexOf(
"("), 0);
141 field = field.substring(0, p + 1) + prefix + field.substring(p + 1);
143 field = prefix + field;
static String logMsg(String msg)
static String putPrefix(String field, String prefix)
static long getNewLongIdFromLong(Dao dao, String table, String field)
static long getNewLongIdFromLong(Dao dao, String table, String field, String fieldConstraints[])
static long getMaxLongIdFromLong(Dao dao, String table, String field, String fieldConstraints[])
static long getMaxLongIdFromLong(Dao dao, String table, String field)
static long getMaxLongIdFromString(Dao dao, String table, String field, String fieldConstraints[])
static long getNewLongIdFromString(Dao dao, String table, String field, String fieldConstraints[])
static long getMaxLongIdFromLong(Dao dao, String table, String field, String fieldConstraints[], boolean count)
static long getMaxLongIdFromString(Dao dao, String table, String field)
static long getNewLongIdFromString(Dao dao, String table, String field)
void addClause(String clause)
static Object convertToClass(Class javaClass, Object value)
Object getSingleNativeResult(String query)
Object getSingleResult(WhereClause wc)