Java Code Examples for com.j256.ormlite.field.SqlType#LONG

The following examples show how to use com.j256.ormlite.field.SqlType#LONG . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HsqldbDatabaseType.java    From ormlite-jdbc with ISC License 6 votes vote down vote up
@Override
protected void configureGeneratedIdSequence(StringBuilder sb, FieldType fieldType, List<String> statementsBefore,
		List<String> additionalArgs, List<String> queriesAfter) {
	// needs to match dropColumnArg()
	StringBuilder seqSb = new StringBuilder(128);
	seqSb.append("CREATE SEQUENCE ");
	appendEscapedEntityName(seqSb, fieldType.getGeneratedIdSequence());
	if (fieldType.getSqlType() == SqlType.LONG) {
		seqSb.append(" AS BIGINT");
	} else {
		// integer is the default
	}
	// with hsqldb (as opposed to all else) the sequences start at 0, grumble
	seqSb.append(" START WITH 1");
	statementsBefore.add(seqSb.toString());
	sb.append("GENERATED BY DEFAULT AS IDENTITY ");
	configureId(sb, fieldType, statementsBefore, additionalArgs, queriesAfter);
}
 
Example 2
Source File: BaseSqliteDatabaseType.java    From ormlite-core with ISC License 5 votes vote down vote up
@Override
protected void appendLongType(StringBuilder sb, FieldType fieldType, int fieldWidth) {
	/*
	 * This is unfortunate. SQLIte requires that a generated-id have the string "INTEGER PRIMARY KEY AUTOINCREMENT"
	 * even though the maximum generated value is 64-bit. See configureGeneratedId below.
	 */
	if (fieldType.getSqlType() == SqlType.LONG && fieldType.isGeneratedId()) {
		sb.append("INTEGER");
	} else {
		sb.append("BIGINT");
	}
}
 
Example 3
Source File: BaseSqliteDatabaseType.java    From ormlite-core with ISC License 5 votes vote down vote up
@Override
protected void configureGeneratedId(String tableName, StringBuilder sb, FieldType fieldType,
		List<String> statementsBefore, List<String> statementsAfter, List<String> additionalArgs,
		List<String> queriesAfter) {
	/*
	 * Even though the documentation talks about INTEGER, it is 64-bit with a maximum value of 9223372036854775807.
	 * See http://www.sqlite.org/faq.html#q1 and http://www.sqlite.org/autoinc.html
	 */
	if (fieldType.getSqlType() != SqlType.INTEGER && fieldType.getSqlType() != SqlType.LONG) {
		throw new IllegalArgumentException(
				"Sqlite requires that auto-increment generated-id be integer or long type");
	}
	sb.append("PRIMARY KEY AUTOINCREMENT ");
	// no additional call to configureId here
}
 
Example 4
Source File: DateTimePersister.java    From ormlite-jdbc with ISC License 4 votes vote down vote up
private DateTimePersister() {
	super(SqlType.LONG, new Class<?>[] { DateTime.class });
}
 
Example 5
Source File: LongType.java    From ormlite-core with ISC License 4 votes vote down vote up
private LongType() {
	super(SqlType.LONG, new Class<?>[] { long.class });
}
 
Example 6
Source File: DateLongType.java    From ormlite-core with ISC License 4 votes vote down vote up
private DateLongType() {
	super(SqlType.LONG);
}
 
Example 7
Source File: LongObjectType.java    From ormlite-core with ISC License 4 votes vote down vote up
private LongObjectType() {
	super(SqlType.LONG, new Class<?>[] { Long.class });
}
 
Example 8
Source File: DateTimeType.java    From ormlite-core with ISC License 4 votes vote down vote up
private DateTimeType() {
	super(SqlType.LONG);
}
 
Example 9
Source File: LongTypeTest.java    From ormlite-core with ISC License 4 votes vote down vote up
@Test
public void testCoverage() {
	new LongType(SqlType.LONG, new Class[0]);
}
 
Example 10
Source File: DateLongTypeTest.java    From ormlite-core with ISC License 4 votes vote down vote up
@Test
public void testCoverage() {
	new DateLongType(SqlType.LONG, new Class[0]);
}