Java Code Examples for org.eclipse.persistence.internal.helper.DatabaseField#setColumnDefinition()
The following examples show how to use
org.eclipse.persistence.internal.helper.DatabaseField#setColumnDefinition() .
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: UuidMappingProcessor.java From cuba with Apache License 2.0 | 6 votes |
private void setDatabaseFieldParameters(Session session, DatabaseField field) { if (session.getPlatform() instanceof PostgreSQLPlatform) { field.setSqlType(Types.OTHER); field.setType(UUID.class); field.setColumnDefinition("UUID"); } else if (session.getPlatform() instanceof MySQLPlatform) { field.setSqlType(Types.VARCHAR); field.setType(String.class); field.setColumnDefinition("varchar(32)"); } else if (session.getPlatform() instanceof HSQLPlatform) { field.setSqlType(Types.VARCHAR); field.setType(String.class); field.setColumnDefinition("varchar(36)"); } else if (session.getPlatform() instanceof SQLServerPlatform) { field.setSqlType(Types.VARCHAR); field.setType(String.class); field.setColumnDefinition("uniqueidentifier"); } else if (session.getPlatform() instanceof OraclePlatform) { field.setSqlType(Types.VARCHAR); field.setType(String.class); field.setColumnDefinition("varchar2(32)"); } else { field.setSqlType(Types.VARCHAR); field.setType(String.class); } }
Example 2
Source File: StudioEclipseLinkSessionEventListener.java From cuba with Apache License 2.0 | 5 votes |
private void setDatabaseFieldParameters(Session session, DatabaseField field) { if (session.getPlatform() instanceof PostgreSQLPlatform) { field.setSqlType(Types.OTHER); field.setType(UUID.class); } else { field.setSqlType(Types.VARCHAR); field.setType(String.class); } field.setColumnDefinition("UUID"); }
Example 3
Source File: JPAMDefaultTableGenerator.java From jeddict with Apache License 2.0 | 4 votes |
/** * Resolve the foreign key database field metadata in relation table or * direct collection/map table. Those metadata includes type, and maybe * dbtype/size/subsize if DatabaseField carries those info. */ protected DatabaseField resolveDatabaseField(DatabaseField childField, DatabaseField parentField) { //set through the type from the source table key field to the relation or direct collection table key field. DatabaseField resolvedDatabaseField = new DatabaseField(); // find original field in the parent table, which contains actual type definitions // if 'resolvedParentField' is null, there is no corresponding field definition (typo?) DatabaseField resolvedParentField = databaseFields.get(parentField); resolvedDatabaseField.setName(childField.getName()); //Table should be set, otherwise other same name field will be used wrongly because equals() is true. //Fix for GF#1392 the same name column for the entity and many-to-many table cause wrong pk constraint. resolvedDatabaseField.setTable(childField.getTable()); // type definitions from parent field definition if (resolvedParentField != null) { resolvedDatabaseField.setType(resolvedParentField.getType()); resolvedDatabaseField.setScale(resolvedParentField.getScale()); resolvedDatabaseField.setLength(resolvedParentField.getLength()); resolvedDatabaseField.setPrecision(resolvedParentField.getPrecision()); } // these are defined in childField definition(see @JoinColumn) resolvedDatabaseField.setUnique(childField.isUnique()); resolvedDatabaseField.setNullable(childField.isNullable()); resolvedDatabaseField.setUpdatable(childField.isUpdatable()); resolvedDatabaseField.setInsertable(childField.isInsertable()); resolvedDatabaseField.setUseDelimiters(childField.shouldUseDelimiters()); resolvedDatabaseField.useUpperCaseForComparisons(childField.getUseUpperCaseForComparisons()); resolvedDatabaseField.setNameForComparisons(childField.getNameForComparisons()); String columnDef = childField.getColumnDefinition(); if (columnDef == null || columnDef.trim().equals("")) { // if childField has no column definition, follow the definition of the parent field if (resolvedParentField != null) { resolvedDatabaseField.setColumnDefinition(resolvedParentField.getColumnDefinition()); } } else { resolvedDatabaseField.setColumnDefinition(columnDef); } return resolvedDatabaseField; }