use of siena.SienaRestrictedApiException in project siena by mandubian.
the class BaseTestNoAutoInc_2_FETCH method testOrderLongAutoId.
public void testOrderLongAutoId() {
if (supportsAutoincrement()) {
List<PersonLongAutoID> people = queryPersonLongAutoIDOrderBy("id", "", false).fetch();
assertNotNull(people);
assertEquals(3, people.size());
PersonLongAutoID[] array = new PersonLongAutoID[] { LongAutoID_TESLA, LongAutoID_CURIE, LongAutoID_EINSTEIN };
int i = 0;
for (PersonLongAutoID person : people) {
assertEquals(array[i], person);
i++;
}
} else {
try {
List<PersonLongAutoID> people = queryPersonLongAutoIDOrderBy("id", "", false).fetch();
} catch (SienaRestrictedApiException ex) {
return;
}
fail();
}
}
use of siena.SienaRestrictedApiException in project siena by mandubian.
the class GaeMappingUtils method createEntityInstance.
public static Entity createEntityInstance(Field idField, ClassInfo info, Object obj) {
Entity entity = null;
Id id = idField.getAnnotation(Id.class);
Class<?> type = idField.getType();
if (id != null) {
switch(id.value()) {
case NONE:
Object idVal = null;
idVal = Util.readField(obj, idField);
if (idVal == null)
throw new SienaException("Id Field " + idField.getName() + " value null");
String keyVal = Util.toString(idField, idVal);
entity = new Entity(info.tableName, keyVal);
break;
case AUTO_INCREMENT:
// manages String ID as not long!!!
if (Long.TYPE == type || Long.class.isAssignableFrom(type)) {
entity = new Entity(info.tableName);
} else {
Object idStringVal = null;
idStringVal = Util.readField(obj, idField);
if (idStringVal == null)
throw new SienaException("Id Field " + idField.getName() + " value null");
String keyStringVal = Util.toString(idField, idStringVal);
entity = new Entity(info.tableName, keyStringVal);
}
break;
case UUID:
entity = new Entity(info.tableName, UUID.randomUUID().toString());
break;
default:
throw new SienaRestrictedApiException("DB", "createEntityInstance", "Id Generator " + id.value() + " not supported");
}
} else
throw new SienaException("Field " + idField.getName() + " is not an @Id field");
return entity;
}
use of siena.SienaRestrictedApiException in project siena by mandubian.
the class JdbcTest method testSearchSingleTwiceInTheSameQuery.
// 2 searches in the same query is not available in Postgres for the time being
public void testSearchSingleTwiceInTheSameQuery() {
Discovery4Search[] discs = new Discovery4Search[100];
for (int i = 0; i < 100; i++) {
discs[i] = new Discovery4Search("Disc_" + i + " " + (100 - i) + "_csid", LongAutoID_CURIE);
}
pm.insert((Object[]) discs);
Query<Discovery4Search> query = pm.createQuery(Discovery4Search.class).search("Disc_5", "name").search("95_csid");
try {
List<Discovery4Search> res = query.fetch();
} catch (SienaRestrictedApiException ex) {
return;
}
fail();
}
Aggregations