mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
No effective change - change newline char and remove extraneous public modifiers on interfaces
This commit is contained in:
@@ -1,46 +1,46 @@
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* API from creating and getting property values from an Immutable Compound
|
||||
* Value Object.
|
||||
*
|
||||
* <p>
|
||||
* A Compound Value object should contain multiple properties that are stored
|
||||
* separately. If you only have a single scalar value you should instead look to
|
||||
* use {@link ScalarTypeConverter}.
|
||||
* </p>
|
||||
* <p>
|
||||
* For each property in the compound type you need to implement the
|
||||
* {@link CompoundTypeProperty} interface. These must be returned from
|
||||
* {@link #getProperties()} in the same order that the properties appear in the
|
||||
* constructor.
|
||||
* </p>
|
||||
* <p>
|
||||
* If your compound type is mutable then you should look to use the JPA Embedded
|
||||
* annotation instead of implementing this interface.
|
||||
* </p>
|
||||
* <p>
|
||||
* When using classpath search Ebean will detect and automatically register any
|
||||
* implementations of this interface (along with detecting the entity classes
|
||||
* etc).
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*
|
||||
* @param <V>
|
||||
* The type of the Value Object
|
||||
*
|
||||
* @see ScalarTypeConverter
|
||||
*/
|
||||
public interface CompoundType<V> {
|
||||
|
||||
/**
|
||||
* Create an instance of the compound type given its property values.
|
||||
*/
|
||||
V create(Object[] propertyValues);
|
||||
|
||||
/**
|
||||
* Return the properties in the order they appear in the constructor.
|
||||
*/
|
||||
CompoundTypeProperty<V, ?>[] getProperties();
|
||||
}
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* API from creating and getting property values from an Immutable Compound
|
||||
* Value Object.
|
||||
*
|
||||
* <p>
|
||||
* A Compound Value object should contain multiple properties that are stored
|
||||
* separately. If you only have a single scalar value you should instead look to
|
||||
* use {@link ScalarTypeConverter}.
|
||||
* </p>
|
||||
* <p>
|
||||
* For each property in the compound type you need to implement the
|
||||
* {@link CompoundTypeProperty} interface. These must be returned from
|
||||
* {@link #getProperties()} in the same order that the properties appear in the
|
||||
* constructor.
|
||||
* </p>
|
||||
* <p>
|
||||
* If your compound type is mutable then you should look to use the JPA Embedded
|
||||
* annotation instead of implementing this interface.
|
||||
* </p>
|
||||
* <p>
|
||||
* When using classpath search Ebean will detect and automatically register any
|
||||
* implementations of this interface (along with detecting the entity classes
|
||||
* etc).
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*
|
||||
* @param <V>
|
||||
* The type of the Value Object
|
||||
*
|
||||
* @see ScalarTypeConverter
|
||||
*/
|
||||
public interface CompoundType<V> {
|
||||
|
||||
/**
|
||||
* Create an instance of the compound type given its property values.
|
||||
*/
|
||||
V create(Object[] propertyValues);
|
||||
|
||||
/**
|
||||
* Return the properties in the order they appear in the constructor.
|
||||
*/
|
||||
CompoundTypeProperty<V, ?>[] getProperties();
|
||||
}
|
||||
|
||||
@@ -1,51 +1,51 @@
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* Represents a Property of a Compound Value Object.
|
||||
* <p>
|
||||
* For each property in a {@link CompoundType} you need an implementation of
|
||||
* this CompoundTypeProperty interface.
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*
|
||||
* @param <V>
|
||||
* The type of the Compound value object
|
||||
* @param <P>
|
||||
* The type of the property
|
||||
*
|
||||
* @see CompoundType
|
||||
* @see ScalarTypeConverter
|
||||
*/
|
||||
public interface CompoundTypeProperty<V, P> {
|
||||
|
||||
/**
|
||||
* The name of this property.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Return the property value from the containing compound value object.
|
||||
*
|
||||
* @param valueObject
|
||||
* the compound value object
|
||||
* @return the property value.
|
||||
*/
|
||||
P getValue(V valueObject);
|
||||
|
||||
/**
|
||||
* This should <b>ONLY</b> be used when the persistence type is different from
|
||||
* the logical type returned. It most cases just return 0 and Ebean will
|
||||
* persist the logical type.
|
||||
* <p>
|
||||
* Typically this should be used when the logical type is long but the
|
||||
* persistence type is java.sql.Timestamp. In this case return
|
||||
* java.sql.Types.TIMESTAMP (rather than 0).
|
||||
* </p>
|
||||
*
|
||||
* @return Return the java.sql.Type that you want to use to persist this
|
||||
* property or 0 and Ebean will use the logical type.
|
||||
*/
|
||||
int getDbType();
|
||||
}
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* Represents a Property of a Compound Value Object.
|
||||
* <p>
|
||||
* For each property in a {@link CompoundType} you need an implementation of
|
||||
* this CompoundTypeProperty interface.
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*
|
||||
* @param <V>
|
||||
* The type of the Compound value object
|
||||
* @param <P>
|
||||
* The type of the property
|
||||
*
|
||||
* @see CompoundType
|
||||
* @see ScalarTypeConverter
|
||||
*/
|
||||
public interface CompoundTypeProperty<V, P> {
|
||||
|
||||
/**
|
||||
* The name of this property.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Return the property value from the containing compound value object.
|
||||
*
|
||||
* @param valueObject
|
||||
* the compound value object
|
||||
* @return the property value.
|
||||
*/
|
||||
P getValue(V valueObject);
|
||||
|
||||
/**
|
||||
* This should <b>ONLY</b> be used when the persistence type is different from
|
||||
* the logical type returned. It most cases just return 0 and Ebean will
|
||||
* persist the logical type.
|
||||
* <p>
|
||||
* Typically this should be used when the logical type is long but the
|
||||
* persistence type is java.sql.Timestamp. In this case return
|
||||
* java.sql.Types.TIMESTAMP (rather than 0).
|
||||
* </p>
|
||||
*
|
||||
* @return Return the java.sql.Type that you want to use to persist this
|
||||
* property or 0 and Ebean will use the logical type.
|
||||
*/
|
||||
int getDbType();
|
||||
}
|
||||
|
||||
@@ -1,111 +1,111 @@
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* Define the encryption options for a bean property.
|
||||
* <p>
|
||||
* You can define the encryption options for a Bean property via the Encrypt
|
||||
* annotation and programmatically via {@link EncryptDeployManager}.
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*
|
||||
* @see EncryptDeployManager#getEncryptDeploy(TableName, String)
|
||||
*/
|
||||
public class EncryptDeploy {
|
||||
|
||||
/**
|
||||
* Use to define that no encryption should be used.
|
||||
*/
|
||||
public static final EncryptDeploy NO_ENCRYPT = new EncryptDeploy(Mode.MODE_NO_ENCRYPT, true, 0);
|
||||
|
||||
/**
|
||||
* Use to define that the Encrypt annotation should be used to control
|
||||
* encryption.
|
||||
*/
|
||||
public static final EncryptDeploy ANNOTATION = new EncryptDeploy(Mode.MODE_ANNOTATION, true, 0);
|
||||
|
||||
/**
|
||||
* Use to define that Encryption should be used and String types should use DB
|
||||
* encryption.
|
||||
*/
|
||||
public static final EncryptDeploy ENCRYPT_DB = new EncryptDeploy(Mode.MODE_ENCRYPT, true, 0);
|
||||
|
||||
/**
|
||||
* Use to define that Java client Encryption should be used (rather than DB
|
||||
* encryption).
|
||||
*/
|
||||
public static final EncryptDeploy ENCRYPT_CLIENT = new EncryptDeploy(Mode.MODE_ENCRYPT, false, 0);
|
||||
|
||||
/**
|
||||
* The Encryption mode.
|
||||
*/
|
||||
public enum Mode {
|
||||
/**
|
||||
* Encrypt the property using DB encryption or Java client encryption
|
||||
* depending on the type and dbEncryption flag.
|
||||
*/
|
||||
MODE_ENCRYPT,
|
||||
|
||||
/**
|
||||
* No encryption is used, even if there is an Encryption annotation on the
|
||||
* property.
|
||||
*/
|
||||
MODE_NO_ENCRYPT,
|
||||
|
||||
/**
|
||||
* Use encryption options defined by the Encryption annotation on the
|
||||
* property. If no annotation is on the property it is not encrypted.
|
||||
*/
|
||||
MODE_ANNOTATION
|
||||
}
|
||||
|
||||
private final Mode mode;
|
||||
|
||||
private final boolean dbEncrypt;
|
||||
|
||||
private final int dbLength;
|
||||
|
||||
/**
|
||||
* Construct with all options for Encryption including the dbLength.
|
||||
*
|
||||
* @param mode
|
||||
* the Encryption mode
|
||||
* @param dbEncrypt
|
||||
* set to false if you want to use Java client side encryption rather
|
||||
* than DB encryption.
|
||||
* @param dbLength
|
||||
* set the DB length to use.
|
||||
*/
|
||||
public EncryptDeploy(Mode mode, boolean dbEncrypt, int dbLength) {
|
||||
this.mode = mode;
|
||||
this.dbEncrypt = dbEncrypt;
|
||||
this.dbLength = dbLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the encryption mode.
|
||||
*/
|
||||
public Mode getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if String type should use DB encryption.
|
||||
* <p>
|
||||
* Return false if String type should use java client encryption instead.
|
||||
* </p>
|
||||
*/
|
||||
public boolean isDbEncrypt() {
|
||||
return dbEncrypt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a hint to specify the DB length.
|
||||
* <p>
|
||||
* Returning 0 means just use the normal DB length determination.
|
||||
* </p>
|
||||
*/
|
||||
public int getDbLength() {
|
||||
return dbLength;
|
||||
}
|
||||
}
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* Define the encryption options for a bean property.
|
||||
* <p>
|
||||
* You can define the encryption options for a Bean property via the Encrypt
|
||||
* annotation and programmatically via {@link EncryptDeployManager}.
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*
|
||||
* @see EncryptDeployManager#getEncryptDeploy(TableName, String)
|
||||
*/
|
||||
public class EncryptDeploy {
|
||||
|
||||
/**
|
||||
* Use to define that no encryption should be used.
|
||||
*/
|
||||
public static final EncryptDeploy NO_ENCRYPT = new EncryptDeploy(Mode.MODE_NO_ENCRYPT, true, 0);
|
||||
|
||||
/**
|
||||
* Use to define that the Encrypt annotation should be used to control
|
||||
* encryption.
|
||||
*/
|
||||
public static final EncryptDeploy ANNOTATION = new EncryptDeploy(Mode.MODE_ANNOTATION, true, 0);
|
||||
|
||||
/**
|
||||
* Use to define that Encryption should be used and String types should use DB
|
||||
* encryption.
|
||||
*/
|
||||
public static final EncryptDeploy ENCRYPT_DB = new EncryptDeploy(Mode.MODE_ENCRYPT, true, 0);
|
||||
|
||||
/**
|
||||
* Use to define that Java client Encryption should be used (rather than DB
|
||||
* encryption).
|
||||
*/
|
||||
public static final EncryptDeploy ENCRYPT_CLIENT = new EncryptDeploy(Mode.MODE_ENCRYPT, false, 0);
|
||||
|
||||
/**
|
||||
* The Encryption mode.
|
||||
*/
|
||||
public enum Mode {
|
||||
/**
|
||||
* Encrypt the property using DB encryption or Java client encryption
|
||||
* depending on the type and dbEncryption flag.
|
||||
*/
|
||||
MODE_ENCRYPT,
|
||||
|
||||
/**
|
||||
* No encryption is used, even if there is an Encryption annotation on the
|
||||
* property.
|
||||
*/
|
||||
MODE_NO_ENCRYPT,
|
||||
|
||||
/**
|
||||
* Use encryption options defined by the Encryption annotation on the
|
||||
* property. If no annotation is on the property it is not encrypted.
|
||||
*/
|
||||
MODE_ANNOTATION
|
||||
}
|
||||
|
||||
private final Mode mode;
|
||||
|
||||
private final boolean dbEncrypt;
|
||||
|
||||
private final int dbLength;
|
||||
|
||||
/**
|
||||
* Construct with all options for Encryption including the dbLength.
|
||||
*
|
||||
* @param mode
|
||||
* the Encryption mode
|
||||
* @param dbEncrypt
|
||||
* set to false if you want to use Java client side encryption rather
|
||||
* than DB encryption.
|
||||
* @param dbLength
|
||||
* set the DB length to use.
|
||||
*/
|
||||
public EncryptDeploy(Mode mode, boolean dbEncrypt, int dbLength) {
|
||||
this.mode = mode;
|
||||
this.dbEncrypt = dbEncrypt;
|
||||
this.dbLength = dbLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the encryption mode.
|
||||
*/
|
||||
public Mode getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if String type should use DB encryption.
|
||||
* <p>
|
||||
* Return false if String type should use java client encryption instead.
|
||||
* </p>
|
||||
*/
|
||||
public boolean isDbEncrypt() {
|
||||
return dbEncrypt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a hint to specify the DB length.
|
||||
* <p>
|
||||
* Returning 0 means just use the normal DB length determination.
|
||||
* </p>
|
||||
*/
|
||||
public int getDbLength() {
|
||||
return dbLength;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* Programmatically define which database columns are encrypted.
|
||||
*
|
||||
* @author rbygrave
|
||||
*
|
||||
*/
|
||||
public interface EncryptDeployManager {
|
||||
|
||||
/**
|
||||
* Return true if the table column is encrypted.
|
||||
*/
|
||||
EncryptDeploy getEncryptDeploy(TableName table, String column);
|
||||
}
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* Programmatically define which database columns are encrypted.
|
||||
*
|
||||
* @author rbygrave
|
||||
*
|
||||
*/
|
||||
public interface EncryptDeployManager {
|
||||
|
||||
/**
|
||||
* Return true if the table column is encrypted.
|
||||
*/
|
||||
EncryptDeploy getEncryptDeploy(TableName table, String column);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* Represents the key used for encryption.
|
||||
* <p>
|
||||
* For simple cases this often represent a simple String key but depending on
|
||||
* the encryption method this could contain other details.
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*/
|
||||
public interface EncryptKey {
|
||||
|
||||
/**
|
||||
* Return the string key value.
|
||||
*/
|
||||
String getStringValue();
|
||||
}
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* Represents the key used for encryption.
|
||||
* <p>
|
||||
* For simple cases this often represent a simple String key but depending on
|
||||
* the encryption method this could contain other details.
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*/
|
||||
public interface EncryptKey {
|
||||
|
||||
/**
|
||||
* Return the string key value.
|
||||
*/
|
||||
String getStringValue();
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* Determine keys used for encryption and decryption.
|
||||
*
|
||||
* @author rbygrave
|
||||
*/
|
||||
public interface EncryptKeyManager {
|
||||
|
||||
/**
|
||||
* Initialise the EncryptKeyManager.
|
||||
* <p>
|
||||
* This gives the EncryptKeyManager the opportunity to get keys etc.
|
||||
* </p>
|
||||
*/
|
||||
void initialise();
|
||||
|
||||
/**
|
||||
* Return the key used to encrypt and decrypt a property mapping to the given
|
||||
* table and column.
|
||||
*/
|
||||
EncryptKey getEncryptKey(String tableName, String columnName);
|
||||
}
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* Determine keys used for encryption and decryption.
|
||||
*
|
||||
* @author rbygrave
|
||||
*/
|
||||
public interface EncryptKeyManager {
|
||||
|
||||
/**
|
||||
* Initialise the EncryptKeyManager.
|
||||
* <p>
|
||||
* This gives the EncryptKeyManager the opportunity to get keys etc.
|
||||
* </p>
|
||||
*/
|
||||
void initialise();
|
||||
|
||||
/**
|
||||
* Return the key used to encrypt and decrypt a property mapping to the given
|
||||
* table and column.
|
||||
*/
|
||||
EncryptKey getEncryptKey(String tableName, String columnName);
|
||||
}
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* Used for Java side encryption of properties when DB encryption is not used.
|
||||
* <p>
|
||||
* By default this is used on non-varchar types such as Blobs.
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*
|
||||
*/
|
||||
public interface Encryptor {
|
||||
|
||||
/**
|
||||
* Encrypt the data using the key.
|
||||
*/
|
||||
byte[] encrypt(byte[] data, EncryptKey key);
|
||||
|
||||
/**
|
||||
* Decrypt the data using the key.
|
||||
*/
|
||||
byte[] decrypt(byte[] data, EncryptKey key);
|
||||
|
||||
/**
|
||||
* Encrypt the formatted string value using a key.
|
||||
*/
|
||||
byte[] encryptString(String formattedValue, EncryptKey key);
|
||||
|
||||
/**
|
||||
* Decrypt the data returning a formatted string value using a key.
|
||||
*/
|
||||
String decryptString(byte[] data, EncryptKey key);
|
||||
|
||||
}
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* Used for Java side encryption of properties when DB encryption is not used.
|
||||
* <p>
|
||||
* By default this is used on non-varchar types such as Blobs.
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*
|
||||
*/
|
||||
public interface Encryptor {
|
||||
|
||||
/**
|
||||
* Encrypt the data using the key.
|
||||
*/
|
||||
byte[] encrypt(byte[] data, EncryptKey key);
|
||||
|
||||
/**
|
||||
* Decrypt the data using the key.
|
||||
*/
|
||||
byte[] decrypt(byte[] data, EncryptKey key);
|
||||
|
||||
/**
|
||||
* Encrypt the formatted string value using a key.
|
||||
*/
|
||||
byte[] encryptString(String formattedValue, EncryptKey key);
|
||||
|
||||
/**
|
||||
* Decrypt the data returning a formatted string value using a key.
|
||||
*/
|
||||
String decryptString(byte[] data, EncryptKey key);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,120 +1,120 @@
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
|
||||
/**
|
||||
* Defines the naming convention for converting between logical property
|
||||
* names/entity names and physical DB column names/table names.
|
||||
* <p>
|
||||
* The main goal of the naming convention is to reduce the amount of
|
||||
* configuration required in the mapping (especially when mapping between column
|
||||
* and property names).
|
||||
* </p>
|
||||
* <p>
|
||||
* Note that if you do not define a NamingConvention the default one will be
|
||||
* used and you can configure it's behaviour via properties.
|
||||
* </p>
|
||||
*/
|
||||
public interface NamingConvention {
|
||||
|
||||
/**
|
||||
* Set the associated DatabasePlaform.
|
||||
* <p>
|
||||
* This is set after the DatabasePlatform has been associated.
|
||||
* </p>
|
||||
* <p>
|
||||
* The purpose of this is to enable NamingConvention to be able to support
|
||||
* database platform specific configuration.
|
||||
* </p>
|
||||
*
|
||||
* @param databasePlatform
|
||||
* the database platform
|
||||
*/
|
||||
void setDatabasePlatform(DatabasePlatform databasePlatform);
|
||||
|
||||
/**
|
||||
* Returns the table name for a given Class.
|
||||
* <p>
|
||||
* This method is always called and should take into account @Table
|
||||
* annotations etc. This means you can choose to override the settings defined
|
||||
* by @Table if you wish.
|
||||
* </p>
|
||||
*
|
||||
* @param beanClass
|
||||
* the bean class
|
||||
*
|
||||
* @return the table name for the entity class
|
||||
*/
|
||||
TableName getTableName(Class<?> beanClass);
|
||||
|
||||
/**
|
||||
* Returns the ManyToMany join table name (aka the intersection table).
|
||||
*
|
||||
* @param lhsTable
|
||||
* the left hand side bean table
|
||||
* @param rhsTable
|
||||
* the right hand side bean table
|
||||
*
|
||||
* @return the many to many join table name
|
||||
*/
|
||||
TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable);
|
||||
|
||||
/**
|
||||
* Return the column name given the property name.
|
||||
*
|
||||
* @return the column name for a given property
|
||||
*/
|
||||
String getColumnFromProperty(Class<?> beanClass, String propertyName);
|
||||
|
||||
/**
|
||||
* Return the property name from the column name.
|
||||
* <p>
|
||||
* This is used to help mapping of raw SQL queries onto bean properties.
|
||||
* </p>
|
||||
*
|
||||
* @param beanClass
|
||||
* the bean class
|
||||
* @param dbColumnName
|
||||
* the db column name
|
||||
*
|
||||
* @return the property name from the column name
|
||||
*/
|
||||
String getPropertyFromColumn(Class<?> beanClass, String dbColumnName);
|
||||
|
||||
/**
|
||||
* Return the sequence name given the table name (for DB's that use
|
||||
* sequences).
|
||||
* <p>
|
||||
* Typically you might append "_seq" to the table name as an example.
|
||||
* </p>
|
||||
*
|
||||
* @param tableName
|
||||
* the table name
|
||||
*
|
||||
* @return the sequence name
|
||||
*/
|
||||
String getSequenceName(String tableName, String pkColumn);
|
||||
|
||||
/**
|
||||
* Return true if a prefix should be used building a foreign key name.
|
||||
* <p>
|
||||
* This by default is true and this works well when the primary key column
|
||||
* names are simply "ID". In this case a prefix (such as "ORDER" and
|
||||
* "CUSTOMER" etc) is added to the foreign key column producing "ORDER_ID" and
|
||||
* "CUSTOMER_ID".
|
||||
* </p>
|
||||
* <p>
|
||||
* This should return false when your primary key columns are the same as the
|
||||
* foreign key columns. For example, when the primary key columns are
|
||||
* "ORDER_ID", "CUST_ID" etc ... and they are the same as the foreign key
|
||||
* column names.
|
||||
* </p>
|
||||
*/
|
||||
boolean isUseForeignKeyPrefix();
|
||||
|
||||
/**
|
||||
* Load setting from properties.
|
||||
*/
|
||||
void loadFromProperties(PropertiesWrapper properties);
|
||||
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
|
||||
/**
|
||||
* Defines the naming convention for converting between logical property
|
||||
* names/entity names and physical DB column names/table names.
|
||||
* <p>
|
||||
* The main goal of the naming convention is to reduce the amount of
|
||||
* configuration required in the mapping (especially when mapping between column
|
||||
* and property names).
|
||||
* </p>
|
||||
* <p>
|
||||
* Note that if you do not define a NamingConvention the default one will be
|
||||
* used and you can configure it's behaviour via properties.
|
||||
* </p>
|
||||
*/
|
||||
public interface NamingConvention {
|
||||
|
||||
/**
|
||||
* Set the associated DatabasePlaform.
|
||||
* <p>
|
||||
* This is set after the DatabasePlatform has been associated.
|
||||
* </p>
|
||||
* <p>
|
||||
* The purpose of this is to enable NamingConvention to be able to support
|
||||
* database platform specific configuration.
|
||||
* </p>
|
||||
*
|
||||
* @param databasePlatform
|
||||
* the database platform
|
||||
*/
|
||||
void setDatabasePlatform(DatabasePlatform databasePlatform);
|
||||
|
||||
/**
|
||||
* Returns the table name for a given Class.
|
||||
* <p>
|
||||
* This method is always called and should take into account @Table
|
||||
* annotations etc. This means you can choose to override the settings defined
|
||||
* by @Table if you wish.
|
||||
* </p>
|
||||
*
|
||||
* @param beanClass
|
||||
* the bean class
|
||||
*
|
||||
* @return the table name for the entity class
|
||||
*/
|
||||
TableName getTableName(Class<?> beanClass);
|
||||
|
||||
/**
|
||||
* Returns the ManyToMany join table name (aka the intersection table).
|
||||
*
|
||||
* @param lhsTable
|
||||
* the left hand side bean table
|
||||
* @param rhsTable
|
||||
* the right hand side bean table
|
||||
*
|
||||
* @return the many to many join table name
|
||||
*/
|
||||
TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable);
|
||||
|
||||
/**
|
||||
* Return the column name given the property name.
|
||||
*
|
||||
* @return the column name for a given property
|
||||
*/
|
||||
String getColumnFromProperty(Class<?> beanClass, String propertyName);
|
||||
|
||||
/**
|
||||
* Return the property name from the column name.
|
||||
* <p>
|
||||
* This is used to help mapping of raw SQL queries onto bean properties.
|
||||
* </p>
|
||||
*
|
||||
* @param beanClass
|
||||
* the bean class
|
||||
* @param dbColumnName
|
||||
* the db column name
|
||||
*
|
||||
* @return the property name from the column name
|
||||
*/
|
||||
String getPropertyFromColumn(Class<?> beanClass, String dbColumnName);
|
||||
|
||||
/**
|
||||
* Return the sequence name given the table name (for DB's that use
|
||||
* sequences).
|
||||
* <p>
|
||||
* Typically you might append "_seq" to the table name as an example.
|
||||
* </p>
|
||||
*
|
||||
* @param tableName
|
||||
* the table name
|
||||
*
|
||||
* @return the sequence name
|
||||
*/
|
||||
String getSequenceName(String tableName, String pkColumn);
|
||||
|
||||
/**
|
||||
* Return true if a prefix should be used building a foreign key name.
|
||||
* <p>
|
||||
* This by default is true and this works well when the primary key column
|
||||
* names are simply "ID". In this case a prefix (such as "ORDER" and
|
||||
* "CUSTOMER" etc) is added to the foreign key column producing "ORDER_ID" and
|
||||
* "CUSTOMER_ID".
|
||||
* </p>
|
||||
* <p>
|
||||
* This should return false when your primary key columns are the same as the
|
||||
* foreign key columns. For example, when the primary key columns are
|
||||
* "ORDER_ID", "CUST_ID" etc ... and they are the same as the foreign key
|
||||
* column names.
|
||||
* </p>
|
||||
*/
|
||||
boolean isUseForeignKeyPrefix();
|
||||
|
||||
/**
|
||||
* Load setting from properties.
|
||||
*/
|
||||
void loadFromProperties(PropertiesWrapper properties);
|
||||
|
||||
}
|
||||
@@ -1,24 +1,24 @@
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
/**
|
||||
* Unwrap the PreparedStatement to get the specific underlying implementation.
|
||||
* <p>
|
||||
* This is used to handle specific JDBC driver issues. Typically this means
|
||||
* getting the OraclePreparedStatement to handle Oracle specific issues etc.
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*/
|
||||
public interface PstmtDelegate {
|
||||
|
||||
/**
|
||||
* Unwrap the PreparedStatement to get the specific underlying implementation.
|
||||
*
|
||||
* @param pstmt
|
||||
* the PreparedStatement coming out of the connection pool
|
||||
* @return the underlying PreparedStatement
|
||||
*/
|
||||
PreparedStatement unwrap(PreparedStatement pstmt);
|
||||
}
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
/**
|
||||
* Unwrap the PreparedStatement to get the specific underlying implementation.
|
||||
* <p>
|
||||
* This is used to handle specific JDBC driver issues. Typically this means
|
||||
* getting the OraclePreparedStatement to handle Oracle specific issues etc.
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*/
|
||||
public interface PstmtDelegate {
|
||||
|
||||
/**
|
||||
* Unwrap the PreparedStatement to get the specific underlying implementation.
|
||||
*
|
||||
* @param pstmt
|
||||
* the PreparedStatement coming out of the connection pool
|
||||
* @return the underlying PreparedStatement
|
||||
*/
|
||||
PreparedStatement unwrap(PreparedStatement pstmt);
|
||||
}
|
||||
|
||||
@@ -1,74 +1,74 @@
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* Used to convert between a value object and a known scalar type. The value
|
||||
* object is the logical type used in your application and the scalar type is
|
||||
* the value used to persist than to the DB.
|
||||
* <p>
|
||||
* The Value object should be immutable and scalar (aka not compound) and
|
||||
* converts to and from a known scalar type which Ebean will use to persist the
|
||||
* value.
|
||||
* </p>
|
||||
* <p>
|
||||
* This is an easier alternative to implementing the
|
||||
* com.avaje.ebean.server.type.ScalarType interface.
|
||||
* </p>
|
||||
* <p>
|
||||
* Note that Ebean will automatically try to detect Immutable Scalar Value
|
||||
* Objects and automatically support them via reflection. This however would not
|
||||
* be appropriate when the logical type is different from the type you wish to
|
||||
* use for persistence - for example, if the logical type was long and you
|
||||
* wanted to use java.sql.Timestamp for persistence. In this case you would want
|
||||
* to implement this interface rather than let Ebean automatically support that
|
||||
* type via reflection.
|
||||
* </p>
|
||||
* <p>
|
||||
* If you want to support a Compound Type rather than a Scalar Type refer to
|
||||
* {@link CompoundType}.
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*
|
||||
* @param <B>
|
||||
* The value object type.
|
||||
* @param <S>
|
||||
* The scalar object type that is used to persist the value object.
|
||||
*
|
||||
* @see CompoundType
|
||||
* @see CompoundTypeProperty
|
||||
*/
|
||||
public interface ScalarTypeConverter<B, S> {
|
||||
|
||||
/**
|
||||
* Return the value to represent null. Typically this is actually null but for
|
||||
* scala.Option and similar type converters this actually returns an instance
|
||||
* representing "None".
|
||||
*/
|
||||
B getNullValue();
|
||||
|
||||
/**
|
||||
* Convert the scalar type value into the value object.
|
||||
* <p>
|
||||
* This typically occurs when Ebean reads the value from a resultSet or other
|
||||
* data source.
|
||||
* </p>
|
||||
*
|
||||
* @param scalarType
|
||||
* the value from the data source
|
||||
*/
|
||||
B wrapValue(S scalarType);
|
||||
|
||||
/**
|
||||
* Convert the value object into a scalar value that Ebean knows how to
|
||||
* persist.
|
||||
* <p>
|
||||
* This typically occurs when Ebean is persisting the value object to the data
|
||||
* store.
|
||||
* </p>
|
||||
*
|
||||
* @param beanType
|
||||
* the value object
|
||||
*/
|
||||
S unwrapValue(B beanType);
|
||||
|
||||
}
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
/**
|
||||
* Used to convert between a value object and a known scalar type. The value
|
||||
* object is the logical type used in your application and the scalar type is
|
||||
* the value used to persist than to the DB.
|
||||
* <p>
|
||||
* The Value object should be immutable and scalar (aka not compound) and
|
||||
* converts to and from a known scalar type which Ebean will use to persist the
|
||||
* value.
|
||||
* </p>
|
||||
* <p>
|
||||
* This is an easier alternative to implementing the
|
||||
* com.avaje.ebean.server.type.ScalarType interface.
|
||||
* </p>
|
||||
* <p>
|
||||
* Note that Ebean will automatically try to detect Immutable Scalar Value
|
||||
* Objects and automatically support them via reflection. This however would not
|
||||
* be appropriate when the logical type is different from the type you wish to
|
||||
* use for persistence - for example, if the logical type was long and you
|
||||
* wanted to use java.sql.Timestamp for persistence. In this case you would want
|
||||
* to implement this interface rather than let Ebean automatically support that
|
||||
* type via reflection.
|
||||
* </p>
|
||||
* <p>
|
||||
* If you want to support a Compound Type rather than a Scalar Type refer to
|
||||
* {@link CompoundType}.
|
||||
* </p>
|
||||
*
|
||||
* @author rbygrave
|
||||
*
|
||||
* @param <B>
|
||||
* The value object type.
|
||||
* @param <S>
|
||||
* The scalar object type that is used to persist the value object.
|
||||
*
|
||||
* @see CompoundType
|
||||
* @see CompoundTypeProperty
|
||||
*/
|
||||
public interface ScalarTypeConverter<B, S> {
|
||||
|
||||
/**
|
||||
* Return the value to represent null. Typically this is actually null but for
|
||||
* scala.Option and similar type converters this actually returns an instance
|
||||
* representing "None".
|
||||
*/
|
||||
B getNullValue();
|
||||
|
||||
/**
|
||||
* Convert the scalar type value into the value object.
|
||||
* <p>
|
||||
* This typically occurs when Ebean reads the value from a resultSet or other
|
||||
* data source.
|
||||
* </p>
|
||||
*
|
||||
* @param scalarType
|
||||
* the value from the data source
|
||||
*/
|
||||
B wrapValue(S scalarType);
|
||||
|
||||
/**
|
||||
* Convert the value object into a scalar value that Ebean knows how to
|
||||
* persist.
|
||||
* <p>
|
||||
* This typically occurs when Ebean is persisting the value object to the data
|
||||
* store.
|
||||
* </p>
|
||||
*
|
||||
* @param beanType
|
||||
* the value object
|
||||
*/
|
||||
S unwrapValue(B beanType);
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user