No effective change - change newline char and remove extraneous public modifiers on interfaces

This commit is contained in:
rbygrave
2015-05-09 00:51:49 +12:00
parent cc200e8607
commit d63eb7abe1
49 changed files with 431 additions and 416 deletions
@@ -17,25 +17,25 @@ public interface Transaction extends Closeable {
* Read Committed transaction isolation. Same as
* java.sql.Connection.TRANSACTION_READ_COMMITTED.
*/
static final int READ_COMMITTED = java.sql.Connection.TRANSACTION_READ_COMMITTED;
int READ_COMMITTED = java.sql.Connection.TRANSACTION_READ_COMMITTED;
/**
* Read Uncommitted transaction isolation. Same as
* java.sql.Connection.TRANSACTION_READ_UNCOMMITTED.
*/
static final int READ_UNCOMMITTED = java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
int READ_UNCOMMITTED = java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
/**
* Repeatable read transaction isolation. Same as
* java.sql.Connection.TRANSACTION_REPEATABLE_READ.
*/
static final int REPEATABLE_READ = java.sql.Connection.TRANSACTION_REPEATABLE_READ;
int REPEATABLE_READ = java.sql.Connection.TRANSACTION_REPEATABLE_READ;
/**
* Serializable transaction isolation. Same as
* java.sql.Connection.TRANSACTION_SERIALIZABLE.
*/
static final int SERIALIZABLE = java.sql.Connection.TRANSACTION_SERIALIZABLE;
int SERIALIZABLE = java.sql.Connection.TRANSACTION_SERIALIZABLE;
/**
* Register a TransactionCallback with this transaction.
@@ -22,7 +22,7 @@ import com.avaje.ebean.ExpressionList;
*/
public interface BeanCollection<E> extends Serializable {
public enum ModifyListenMode {
enum ModifyListenMode {
/** The common mode */
NONE,
/** Mode used for PrivateOwned */
@@ -36,23 +36,23 @@ public interface BeanCollection<E> extends Serializable {
* <p>
* This is done as part of bean refresh.
*/
public void reset(EntityBean ownerBean, String propertyName);
void reset(EntityBean ownerBean, String propertyName);
/**
* Return true if the collection is empty and untouched. Used to detect if a
* collection was 'cleared' deliberately or just un-initialised.
*/
public boolean isEmptyAndUntouched();
boolean isEmptyAndUntouched();
/**
* Return the bean that owns this collection.
*/
public EntityBean getOwnerBean();
EntityBean getOwnerBean();
/**
* Return the bean property name this collection represents.
*/
public String getPropertyName();
String getPropertyName();
/**
* Check after the lazy load that the underlying collection is not null
@@ -62,7 +62,7 @@ public interface BeanCollection<E> extends Serializable {
* then make sure the collection is set to empty.
* </p>
*/
public boolean checkEmptyLazyLoad();
boolean checkEmptyLazyLoad();
/**
* Return the filter (if any) that was used in building this collection.
@@ -70,22 +70,22 @@ public interface BeanCollection<E> extends Serializable {
* This is so that the filter can be applied on refresh.
* </p>
*/
public ExpressionList<?> getFilterMany();
ExpressionList<?> getFilterMany();
/**
* Set the filter that was used in building this collection.
*/
public void setFilterMany(ExpressionList<?> filterMany);
void setFilterMany(ExpressionList<?> filterMany);
/**
* Set a listener to be notified when the BeanCollection is first touched.
*/
public void setBeanCollectionTouched(BeanCollectionTouched notify);
void setBeanCollectionTouched(BeanCollectionTouched notify);
/**
* Return true if the collection has been registered with the batch loading context.
*/
public boolean isRegisteredWithLoadContext();
boolean isRegisteredWithLoadContext();
/**
* Set the loader that will be used to lazy/query load this collection.
@@ -93,19 +93,19 @@ public interface BeanCollection<E> extends Serializable {
* This is effectively the batch loading context this collection is registered with.
* </p>
*/
public void setLoader(BeanCollectionLoader beanLoader);
void setLoader(BeanCollectionLoader beanLoader);
/**
* Set to true if you want the BeanCollection to be treated as read only. This
* means no elements can be added or removed etc.
*/
public void setReadOnly(boolean readOnly);
void setReadOnly(boolean readOnly);
/**
* Return true if the collection should be treated as readOnly and no elements
* can be added or removed etc.
*/
public boolean isReadOnly();
boolean isReadOnly();
/**
* Add the bean to the collection.
@@ -113,22 +113,22 @@ public interface BeanCollection<E> extends Serializable {
* This is disallowed for BeanMap.
* </p>
*/
public void internalAdd(Object bean);
void internalAdd(Object bean);
/**
* Return the number of elements in the List Set or Map.
*/
public int size();
int size();
/**
* Return true if the List Set or Map is empty.
*/
public boolean isEmpty();
boolean isEmpty();
/**
* Returns the underlying collection of beans from the Set, Map or List.
*/
public Collection<E> getActualDetails();
Collection<E> getActualDetails();
/**
* Returns the underlying entries so for Maps this is a collection of
@@ -137,20 +137,20 @@ public interface BeanCollection<E> extends Serializable {
* For maps this returns the entrySet as we need the keys of the map.
* </p>
*/
public Collection<?> getActualEntries();
Collection<?> getActualEntries();
/**
* return true if there are real rows held. Return false is this is using
* Deferred fetch to lazy load the rows and the rows have not yet been
* fetched.
*/
public boolean isPopulated();
boolean isPopulated();
/**
* Return true if this is a reference (lazy loading) bean collection. This is
* the same as !isPopulated();
*/
public boolean isReference();
boolean isReference();
/**
* Set modify listening on or off. This is used to keep track of objects that
@@ -161,7 +161,7 @@ public interface BeanCollection<E> extends Serializable {
* Otherwise modifyListening is false.
* </p>
*/
public void setModifyListening(ModifyListenMode modifyListenMode);
void setModifyListening(ModifyListenMode modifyListenMode);
/**
* Add an object to the additions list.
@@ -170,7 +170,7 @@ public interface BeanCollection<E> extends Serializable {
* ManyToMany.
* </p>
*/
public void modifyAddition(E bean);
void modifyAddition(E bean);
/**
* Add an object to the deletions list.
@@ -179,23 +179,23 @@ public interface BeanCollection<E> extends Serializable {
* ManyToMany.
* </p>
*/
public void modifyRemoval(Object bean);
void modifyRemoval(Object bean);
/**
* Return the list of objects added to the list set or map. These will used to
* insert rows into the intersection table of a ManyToMany.
*/
public Set<E> getModifyAdditions();
Set<E> getModifyAdditions();
/**
* Return the list of objects removed from the list set or map. These will
* used to delete rows from the intersection table of a ManyToMany.
*/
public Set<E> getModifyRemovals();
Set<E> getModifyRemovals();
/**
* Reset the set of additions and deletions. This is called after the
* additions and removals have been processed.
*/
public void modifyReset();
void modifyReset();
}
@@ -12,5 +12,5 @@ public interface BeanCollectionAdd {
/**
* Add a loaded bean to the collection.
*/
public void addBean(EntityBean bean);
void addBean(EntityBean bean);
}
@@ -11,11 +11,11 @@ public interface BeanCollectionLoader {
/**
* Return the name of the associated EbeanServer.
*/
public String getName();
String getName();
/**
* Invoke the lazy loading for this bean collection.
*/
public void loadMany(BeanCollection<?> collection, boolean onlyIds);
void loadMany(BeanCollection<?> collection, boolean onlyIds);
}
@@ -16,5 +16,5 @@ public interface BeanCollectionTouched {
/**
* Notify the listener that the bean collection has been used.
*/
public void notifyTouched(BeanCollection<?> c);
void notifyTouched(BeanCollection<?> c);
}
@@ -11,11 +11,11 @@ public interface BeanLoader {
/**
* Return the name of the associated EbeanServer.
*/
public String getName();
String getName();
/**
* Invoke the lazy loading for this bean.
*/
public void loadBean(EntityBeanIntercept ebi);
void loadBean(EntityBeanIntercept ebi);
}
@@ -14,9 +14,9 @@ import java.io.Serializable;
*/
public interface EntityBean extends Serializable {
public String[] _ebean_getPropertyNames();
String[] _ebean_getPropertyNames();
public String _ebean_getPropertyName(int pos);
String _ebean_getPropertyName(int pos);
/**
* Return the enhancement marker value.
@@ -25,38 +25,38 @@ public interface EntityBean extends Serializable {
* entity classes are enhanced (specifically not just a super class).
* </p>
*/
public String _ebean_getMarker();
String _ebean_getMarker();
/**
* Create and return a new entity bean instance.
*/
public Object _ebean_newInstance();
Object _ebean_newInstance();
/**
* Add a PropertyChangeListener to this bean.
*/
public void addPropertyChangeListener(PropertyChangeListener listener);
void addPropertyChangeListener(PropertyChangeListener listener);
/**
* Remove a PropertyChangeListener from this bean.
*/
public void removePropertyChangeListener(PropertyChangeListener listener);
void removePropertyChangeListener(PropertyChangeListener listener);
/**
* Generated method that sets the loaded state on all the embedded beans on
* this entity bean by using EntityBeanIntercept.setEmbeddedLoaded(Object o);
*/
public void _ebean_setEmbeddedLoaded();
void _ebean_setEmbeddedLoaded();
/**
* Return true if any embedded beans are new or dirty.
*/
public boolean _ebean_isEmbeddedNewOrDirty();
boolean _ebean_isEmbeddedNewOrDirty();
/**
* Return the intercept for this object.
*/
public EntityBeanIntercept _ebean_getIntercept();
EntityBeanIntercept _ebean_getIntercept();
/**
* Similar to _ebean_getIntercept() except it checks to see if the intercept
@@ -71,7 +71,7 @@ public interface EntityBean extends Serializable {
* frameworks that can't take into account our ebean fields.
* </p>
*/
public EntityBeanIntercept _ebean_intercept();
EntityBeanIntercept _ebean_intercept();
/**
* Create a copy of this entity bean.
@@ -81,7 +81,7 @@ public interface EntityBean extends Serializable {
* optimistic concurrency control.
* </p>
*/
public Object _ebean_createCopy();
Object _ebean_createCopy();
/**
* Set the value of a field of an entity bean of this type.
@@ -90,12 +90,12 @@ public interface EntityBean extends Serializable {
* on entity beans. That means lazy loading and oldValues creation.
* </p>
*/
public void _ebean_setField(int fieldIndex, Object value);
void _ebean_setField(int fieldIndex, Object value);
/**
* Set the field value with interception.
*/
public void _ebean_setFieldIntercept(int fieldIndex, Object value);
void _ebean_setFieldIntercept(int fieldIndex, Object value);
/**
* Return the value of a field from an entity bean of this type.
@@ -104,11 +104,11 @@ public interface EntityBean extends Serializable {
* on entity beans. That means lazy loading.
* </p>
*/
public Object _ebean_getField(int fieldIndex);
Object _ebean_getField(int fieldIndex);
/**
* Return the field value with interception.
*/
public Object _ebean_getFieldIntercept(int fieldIndex);
Object _ebean_getFieldIntercept(int fieldIndex);
}
@@ -12,5 +12,5 @@ public interface NodeUsageListener {
* This information is used by autoFetch to tune queries.
* </p>
*/
public void collectNodeUsage(NodeUsageCollector collector);
void collectNodeUsage(NodeUsageCollector collector);
}
@@ -12,7 +12,7 @@ public interface PersistenceContext {
/**
* Put the entity bean into the PersistanceContext.
*/
public void put(Object id, Object bean);
void put(Object id, Object bean);
/**
* Put the entity bean into the PersistanceContext if one is not already
@@ -22,44 +22,44 @@ public interface PersistenceContext {
* returns null.
* </p>
*/
public Object putIfAbsent(Object id, Object bean);
Object putIfAbsent(Object id, Object bean);
/**
* Return an object given its type and unique id.
*/
public Object get(Class<?> beanType, Object uid);
Object get(Class<?> beanType, Object uid);
/**
* Get the bean from the persistence context also checked to see if it had
* been previously deleted (if so then you also can't hit the L2 cache to
* fetch the bean for this particular persistence context).
*/
public WithOption getWithOption(Class<?> beanType, Object uid);
WithOption getWithOption(Class<?> beanType, Object uid);
/**
* Clear all the references.
*/
public void clear();
void clear();
/**
* Clear all the references for a given type of entity bean.
*/
public void clear(Class<?> beanType);
void clear(Class<?> beanType);
/**
* Clear the reference to a specific entity bean.
*/
public void clear(Class<?> beanType, Object uid);
void clear(Class<?> beanType, Object uid);
/**
* Clear the reference as a result of an entity being deleted.
*/
public void deleted(Class<?> beanType, Object id);
void deleted(Class<?> beanType, Object id);
/**
* Return the number of beans of the given type in the persistence context.
*/
public int size(Class<?> beanType);
int size(Class<?> beanType);
/**
* Wrapper on a bean to also indicate if a bean has been deleted.
@@ -68,7 +68,7 @@ public interface PersistenceContext {
* not be able to be fetched from persistence context or L2 cache.
* </p>
*/
public static class WithOption {
class WithOption {
/**
* The bean was previously deleted from this persistence context (can't hit
+11 -11
View File
@@ -26,38 +26,38 @@ public interface ServerCache {
* is made available for use.
* </p>
*/
public void init(EbeanServer ebeanServer);
void init(EbeanServer ebeanServer);
/**
* Return the configuration options for this cache.
*/
public ServerCacheOptions getOptions();
ServerCacheOptions getOptions();
/**
* Update the configuration options for this cache.
*/
public void setOptions(ServerCacheOptions options);
void setOptions(ServerCacheOptions options);
/**
* Return the value given the key.
*/
public Object get(Object id);
Object get(Object id);
/**
* Put the value in the cache with a given id.
*/
public Object put(Object id, Object value);
Object put(Object id, Object value);
/**
* Put the value in the cache but only if a matching value is not already in
* the cache.
*/
public Object putIfAbsent(Object id, Object value);
Object putIfAbsent(Object id, Object value);
/**
* Remove a entry from the cache given its id.
*/
public Object remove(Object id);
Object remove(Object id);
/**
* Clear all entries from the cache.
@@ -67,17 +67,17 @@ public interface ServerCache {
* be done via {@link ServerCacheManager#clear(Class)}.
* </p>
*/
public void clear();
void clear();
/**
* Return the number of entries in the cache.
*/
public int size();
int size();
/**
* Return the hit ratio the cache is currently getting.
*/
public int getHitRatio();
int getHitRatio();
/**
* Return statistics for the cache.
@@ -85,5 +85,5 @@ public interface ServerCache {
* @param reset
* if true the statistics are reset.
*/
public ServerCacheStatistics getStatistics(boolean reset);
ServerCacheStatistics getStatistics(boolean reset);
}
@@ -16,11 +16,11 @@ public interface ServerCacheFactory {
* cache trimming/cleanup.
* </p>
*/
public void init(EbeanServer ebeanServer);
void init(EbeanServer ebeanServer);
/**
* Create the cache for the given type with options.
*/
public ServerCache createCache(String cacheKey, ServerCacheOptions cacheOptions);
ServerCache createCache(String cacheKey, ServerCacheOptions cacheOptions);
}
@@ -16,40 +16,40 @@ public interface ServerCacheManager {
* background trimming of the cache.
* </p>
*/
public void init(EbeanServer server);
void init(EbeanServer server);
public void setCaching(Class<?> beanType, boolean useCache);
void setCaching(Class<?> beanType, boolean useCache);
/**
* Return true if there is an active bean cache for this type of bean.
*/
public boolean isBeanCaching(Class<?> beanType);
boolean isBeanCaching(Class<?> beanType);
/**
* Return the cache for mapping natural keys to id values.
*/
public ServerCache getNaturalKeyCache(Class<?> beanType);
ServerCache getNaturalKeyCache(Class<?> beanType);
/**
* Return the cache for beans of a particular type.
*/
public ServerCache getBeanCache(Class<?> beanType);
ServerCache getBeanCache(Class<?> beanType);
public ServerCache getCollectionIdsCache(Class<?> beanType, String propertyName);
ServerCache getCollectionIdsCache(Class<?> beanType, String propertyName);
/**
* Return the cache for query results of a particular type of bean.
*/
public ServerCache getQueryCache(Class<?> beanType);
ServerCache getQueryCache(Class<?> beanType);
/**
* This clears both the bean and query cache for a given type.
*/
public void clear(Class<?> beanType);
void clear(Class<?> beanType);
/**
* Clear all the caches.
*/
public void clearAll();
void clearAll();
}
@@ -37,10 +37,10 @@ public interface CompoundType<V> {
/**
* Create an instance of the compound type given its property values.
*/
public V create(Object[] propertyValues);
V create(Object[] propertyValues);
/**
* Return the properties in the order they appear in the constructor.
*/
public CompoundTypeProperty<V, ?>[] getProperties();
CompoundTypeProperty<V, ?>[] getProperties();
}
@@ -23,7 +23,7 @@ public interface CompoundTypeProperty<V, P> {
/**
* The name of this property.
*/
public String getName();
String getName();
/**
* Return the property value from the containing compound value object.
@@ -32,7 +32,7 @@ public interface CompoundTypeProperty<V, P> {
* the compound value object
* @return the property value.
*/
public P getValue(V valueObject);
P getValue(V valueObject);
/**
* This should <b>ONLY</b> be used when the persistence type is different from
@@ -47,5 +47,5 @@ public interface CompoundTypeProperty<V, 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.
*/
public int getDbType();
int getDbType();
}
@@ -11,5 +11,5 @@ public interface EncryptDeployManager {
/**
* Return true if the table column is encrypted.
*/
public EncryptDeploy getEncryptDeploy(TableName table, String column);
EncryptDeploy getEncryptDeploy(TableName table, String column);
}
@@ -14,5 +14,5 @@ public interface EncryptKey {
/**
* Return the string key value.
*/
public String getStringValue();
String getStringValue();
}
@@ -13,11 +13,11 @@ public interface EncryptKeyManager {
* This gives the EncryptKeyManager the opportunity to get keys etc.
* </p>
*/
public void initialise();
void initialise();
/**
* Return the key used to encrypt and decrypt a property mapping to the given
* table and column.
*/
public EncryptKey getEncryptKey(String tableName, String columnName);
EncryptKey getEncryptKey(String tableName, String columnName);
}
@@ -14,21 +14,21 @@ public interface Encryptor {
/**
* Encrypt the data using the key.
*/
public byte[] encrypt(byte[] data, EncryptKey key);
byte[] encrypt(byte[] data, EncryptKey key);
/**
* Decrypt the data using the key.
*/
public byte[] decrypt(byte[] data, EncryptKey key);
byte[] decrypt(byte[] data, EncryptKey key);
/**
* Encrypt the formatted string value using a key.
*/
public byte[] encryptString(String formattedValue, EncryptKey key);
byte[] encryptString(String formattedValue, EncryptKey key);
/**
* Decrypt the data returning a formatted string value using a key.
*/
public String decryptString(byte[] data, EncryptKey key);
String decryptString(byte[] data, EncryptKey key);
}
@@ -11,11 +11,11 @@ public interface ExternalTransactionManager {
* This will change when SPI is published but will do for now.
* </p>
*/
public void setTransactionManager(Object transactionManager);
void setTransactionManager(Object transactionManager);
/**
* Return the current transaction or null if there is none.
*/
public Object getCurrentTransaction();
Object getCurrentTransaction();
}
@@ -30,7 +30,7 @@ public interface NamingConvention {
* @param databasePlatform
* the database platform
*/
public void setDatabasePlatform(DatabasePlatform databasePlatform);
void setDatabasePlatform(DatabasePlatform databasePlatform);
/**
* Returns the table name for a given Class.
@@ -45,7 +45,7 @@ public interface NamingConvention {
*
* @return the table name for the entity class
*/
public TableName getTableName(Class<?> beanClass);
TableName getTableName(Class<?> beanClass);
/**
* Returns the ManyToMany join table name (aka the intersection table).
@@ -57,14 +57,14 @@ public interface NamingConvention {
*
* @return the many to many join table name
*/
public TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable);
TableName getM2MJoinTableName(TableName lhsTable, TableName rhsTable);
/**
* Return the column name given the property name.
*
* @return the column name for a given property
*/
public String getColumnFromProperty(Class<?> beanClass, String propertyName);
String getColumnFromProperty(Class<?> beanClass, String propertyName);
/**
* Return the property name from the column name.
@@ -79,7 +79,7 @@ public interface NamingConvention {
*
* @return the property name from the column name
*/
public String getPropertyFromColumn(Class<?> beanClass, String dbColumnName);
String getPropertyFromColumn(Class<?> beanClass, String dbColumnName);
/**
* Return the sequence name given the table name (for DB's that use
@@ -93,7 +93,7 @@ public interface NamingConvention {
*
* @return the sequence name
*/
public String getSequenceName(String tableName, String pkColumn);
String getSequenceName(String tableName, String pkColumn);
/**
* Return true if a prefix should be used building a foreign key name.
@@ -110,11 +110,11 @@ public interface NamingConvention {
* column names.
* </p>
*/
public boolean isUseForeignKeyPrefix();
boolean isUseForeignKeyPrefix();
/**
* Load setting from properties.
*/
public void loadFromProperties(PropertiesWrapper properties);
void loadFromProperties(PropertiesWrapper properties);
}
@@ -20,5 +20,5 @@ public interface PstmtDelegate {
* the PreparedStatement coming out of the connection pool
* @return the underlying PreparedStatement
*/
public PreparedStatement unwrap(PreparedStatement pstmt);
PreparedStatement unwrap(PreparedStatement pstmt);
}
@@ -44,7 +44,7 @@ public interface ScalarTypeConverter<B, S> {
* scala.Option and similar type converters this actually returns an instance
* representing "None".
*/
public B getNullValue();
B getNullValue();
/**
* Convert the scalar type value into the value object.
@@ -56,7 +56,7 @@ public interface ScalarTypeConverter<B, S> {
* @param scalarType
* the value from the data source
*/
public B wrapValue(S scalarType);
B wrapValue(S scalarType);
/**
* Convert the value object into a scalar value that Ebean knows how to
@@ -69,6 +69,6 @@ public interface ScalarTypeConverter<B, S> {
* @param beanType
* the value object
*/
public S unwrapValue(B beanType);
S unwrapValue(B beanType);
}
@@ -1,172 +1,172 @@
package com.avaje.ebean.config;
/**
* Converts between Camel Case and Underscore based names for both table and
* column names (and is the default naming convention in Ebean).
*
* @author emcgreal
* @author rbygrave
*/
public class UnderscoreNamingConvention extends AbstractNamingConvention {
/** Force toUnderscore to return in upper case. */
private boolean forceUpperCase = false;
/** The digits compressed. */
private boolean digitsCompressed = true;
/**
* Create with a given sequence format.
*
* @param sequenceFormat
* the sequence format
*/
public UnderscoreNamingConvention(String sequenceFormat) {
super(sequenceFormat);
}
/**
* Create with a sequence format of "{table}_seq".
*/
public UnderscoreNamingConvention() {
super();
}
/**
* Returns the last part of the class name.
*
* @param beanClass
* the bean class
*
* @return the table name from class
*/
public TableName getTableNameByConvention(Class<?> beanClass) {
return new TableName(getCatalog(),
getSchema(),
toUnderscoreFromCamel(beanClass.getSimpleName()));
}
/**
* Converts Camel case property name to underscore based column name.
*
* @return the column from property
*/
public String getColumnFromProperty(Class<?> beanClass, String propertyName) {// Field
// field)
// {
return toUnderscoreFromCamel(propertyName);
}
/**
* Converts underscore based column name to Camel case property name.
*
* @param beanClass
* the bean class
* @param dbColumnName
* the db column name
*
* @return the property from column
*/
public String getPropertyFromColumn(Class<?> beanClass, String dbColumnName) {
return toCamelFromUnderscore(dbColumnName);
}
/**
* Return true if the result will be upper case.
* <p>
* False if it will be lower case.
* </p>
*/
public boolean isForceUpperCase() {
return forceUpperCase;
}
/**
* Set to true to make the result upper case.
*/
public void setForceUpperCase(boolean forceUpperCase) {
this.forceUpperCase = forceUpperCase;
}
/**
* Returns true if digits are compressed.
*/
public boolean isDigitsCompressed() {
return digitsCompressed;
}
/**
* Sets to true for digits to be compressed (without a leading underscore).
*/
public void setDigitsCompressed(boolean digitsCompressed) {
this.digitsCompressed = digitsCompressed;
}
/**
* Convert and return the string to underscore from camel case.
*/
protected String toUnderscoreFromCamel(String camelCase) {
int lastUpper = -1;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < camelCase.length(); i++) {
char c = camelCase.charAt(i);
if ('_' == c) {
// Underscores should just be passed through
sb.append(c);
lastUpper = i;
} else if (Character.isDigit(c)) {
if (i > lastUpper + 1 && !digitsCompressed) {
sb.append("_");
}
sb.append(c);
lastUpper = i;
} else if (Character.isUpperCase(c)) {
if (i > lastUpper + 1) {
sb.append("_");
}
sb.append(Character.toLowerCase(c));
lastUpper = i;
} else {
sb.append(c);
}
}
String ret = sb.toString();
if (forceUpperCase) {
ret = ret.toUpperCase();
}
return ret;
}
/**
* To camel from underscore.
*
* @param underscore
* the underscore
*
* @return the string
*/
protected String toCamelFromUnderscore(String underscore) {
StringBuffer result = new StringBuffer();
String[] vals = underscore.split("_");
for (int i = 0; i < vals.length; i++) {
String lower = vals[i].toLowerCase();
if (i > 0) {
char c = Character.toUpperCase(lower.charAt(0));
result.append(c);
result.append(lower.substring(1));
} else {
result.append(lower);
}
}
return result.toString();
}
}
package com.avaje.ebean.config;
/**
* Converts between Camel Case and Underscore based names for both table and
* column names (and is the default naming convention in Ebean).
*
* @author emcgreal
* @author rbygrave
*/
public class UnderscoreNamingConvention extends AbstractNamingConvention {
/** Force toUnderscore to return in upper case. */
private boolean forceUpperCase = false;
/** The digits compressed. */
private boolean digitsCompressed = true;
/**
* Create with a given sequence format.
*
* @param sequenceFormat
* the sequence format
*/
public UnderscoreNamingConvention(String sequenceFormat) {
super(sequenceFormat);
}
/**
* Create with a sequence format of "{table}_seq".
*/
public UnderscoreNamingConvention() {
super();
}
/**
* Returns the last part of the class name.
*
* @param beanClass
* the bean class
*
* @return the table name from class
*/
public TableName getTableNameByConvention(Class<?> beanClass) {
return new TableName(getCatalog(),
getSchema(),
toUnderscoreFromCamel(beanClass.getSimpleName()));
}
/**
* Converts Camel case property name to underscore based column name.
*
* @return the column from property
*/
public String getColumnFromProperty(Class<?> beanClass, String propertyName) {// Field
// field)
// {
return toUnderscoreFromCamel(propertyName);
}
/**
* Converts underscore based column name to Camel case property name.
*
* @param beanClass
* the bean class
* @param dbColumnName
* the db column name
*
* @return the property from column
*/
public String getPropertyFromColumn(Class<?> beanClass, String dbColumnName) {
return toCamelFromUnderscore(dbColumnName);
}
/**
* Return true if the result will be upper case.
* <p>
* False if it will be lower case.
* </p>
*/
public boolean isForceUpperCase() {
return forceUpperCase;
}
/**
* Set to true to make the result upper case.
*/
public void setForceUpperCase(boolean forceUpperCase) {
this.forceUpperCase = forceUpperCase;
}
/**
* Returns true if digits are compressed.
*/
public boolean isDigitsCompressed() {
return digitsCompressed;
}
/**
* Sets to true for digits to be compressed (without a leading underscore).
*/
public void setDigitsCompressed(boolean digitsCompressed) {
this.digitsCompressed = digitsCompressed;
}
/**
* Convert and return the string to underscore from camel case.
*/
protected String toUnderscoreFromCamel(String camelCase) {
int lastUpper = -1;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < camelCase.length(); i++) {
char c = camelCase.charAt(i);
if ('_' == c) {
// Underscores should just be passed through
sb.append(c);
lastUpper = i;
} else if (Character.isDigit(c)) {
if (i > lastUpper + 1 && !digitsCompressed) {
sb.append("_");
}
sb.append(c);
lastUpper = i;
} else if (Character.isUpperCase(c)) {
if (i > lastUpper + 1) {
sb.append("_");
}
sb.append(Character.toLowerCase(c));
lastUpper = i;
} else {
sb.append(c);
}
}
String ret = sb.toString();
if (forceUpperCase) {
ret = ret.toUpperCase();
}
return ret;
}
/**
* To camel from underscore.
*
* @param underscore
* the underscore
*
* @return the string
*/
protected String toCamelFromUnderscore(String underscore) {
StringBuffer result = new StringBuffer();
String[] vals = underscore.split("_");
for (int i = 0; i < vals.length; i++) {
String lower = vals[i].toLowerCase();
if (i > 0) {
char c = Character.toUpperCase(lower.charAt(0));
result.append(c);
result.append(lower.substring(1));
} else {
result.append(lower);
}
}
return result.toString();
}
}
@@ -16,15 +16,15 @@ public interface DbEncrypt {
// /**
// * Return the SQL for decrypting a column returning a VARCHAR.
// */
// public String getDecryptSql(String columnWithTableAlias);
// String getDecryptSql(String columnWithTableAlias);
//
// /**
// * Return the DB function with bind variables used to encrypt a VARCHAR
// * value.
// */
// public String getEncryptBindSql();
// String getEncryptBindSql();
public DbEncryptFunction getDbEncryptFunction(int jdbcType);
DbEncryptFunction getDbEncryptFunction(int jdbcType);
/**
* Return the DB type that encrypted Strings are stored in.
@@ -32,10 +32,10 @@ public interface DbEncrypt {
* This is VARCHAR for MySql and VARBINARY for most others.
* </p>
*/
public int getEncryptDbType();
int getEncryptDbType();
/**
* Return true if the DB encrypt function binds the data before the key.
*/
public boolean isBindEncryptDataFirst();
boolean isBindEncryptDataFirst();
}
@@ -5,11 +5,11 @@ public interface DbEncryptFunction {
/**
* Return the SQL for decrypting a column returning a VARCHAR.
*/
public String getDecryptSql(String columnWithTableAlias);
String getDecryptSql(String columnWithTableAlias);
/**
* Return the DB function with bind variables used to encrypt a VARCHAR value.
*/
public String getEncryptBindSql();
String getEncryptBindSql();
}
@@ -16,18 +16,18 @@ public interface IdGenerator {
/**
* The name of the default UUID generator.
*/
public static final String AUTO_UUID = "auto.uuid";
static final String AUTO_UUID = "auto.uuid";
/**
* Return the name of the IdGenerator. For sequences this is the sequence
* name.
*/
public String getName();
String getName();
/**
* Return true if this is a DB sequence.
*/
public boolean isDbSequence();
boolean isDbSequence();
/**
* return the next unique identity value.
@@ -35,7 +35,7 @@ public interface IdGenerator {
* Note the transaction passed in can be null.
* </p>
*/
public Object nextId(Transaction transaction);
Object nextId(Transaction transaction);
/**
* Is called prior to inserting OneToMany's as an indication that a number of
@@ -45,6 +45,6 @@ public interface IdGenerator {
* Especially when the allocateSize is very large.
* </p>
*/
public void preAllocateIds(int allocateSize);
void preAllocateIds(int allocateSize);
}
@@ -11,35 +11,35 @@ public interface SqlLimitRequest {
/**
* Return true if the query uses distinct.
*/
public boolean isDistinct();
boolean isDistinct();
/**
* Return the first row value.
*/
public int getFirstRow();
int getFirstRow();
/**
* Return the max rows for this query.
*/
public int getMaxRows();
int getMaxRows();
/**
* Return the sql query.
*/
public String getDbSql();
String getDbSql();
/**
* Return the orderBy clause of the sql query.
*/
public String getDbOrderBy();
String getDbOrderBy();
/**
* return the query
*/
public Query<?> getOrmQuery();
Query<?> getOrmQuery();
/**
* return the database platform
*/
public DatabasePlatform getDbPlatform();
DatabasePlatform getDbPlatform();
}
@@ -11,15 +11,15 @@ public interface SqlLimiter {
* Note that this is removed for logging sql to the transaction log.
* </p>
*/
public static final char NEW_LINE = '\n';
static final char NEW_LINE = '\n';
/**
* The carriage return character.
*/
public static final char CARRIAGE_RETURN = '\r';
static final char CARRIAGE_RETURN = '\r';
/**
* Add the SQL limiting statements around the query.
*/
public SqlLimitResponse limit(SqlLimitRequest request);
SqlLimitResponse limit(SqlLimitRequest request);
}
@@ -20,7 +20,7 @@ public interface BeanFinder<T> {
/**
* Find a bean using its id or unique predicate.
*/
public T find(BeanQueryRequest<T> request);
T find(BeanQueryRequest<T> request);
/**
* Return a List, Set or Map for the given find request.
@@ -29,6 +29,6 @@ public interface BeanFinder<T> {
* get the return type right.
* </p>
*/
public BeanCollection<T> findMany(BeanQueryRequest<T> request);
BeanCollection<T> findMany(BeanQueryRequest<T> request);
}
@@ -53,13 +53,13 @@ public interface BeanPersistController {
* @return an int used to control the order BeanPersistController's are
* executed
*/
public int getExecutionOrder();
int getExecutionOrder();
/**
* Return true if this BeanPersistController should be registered for events
* on this entity type.
*/
public boolean isRegisterFor(Class<?> cls);
boolean isRegisterFor(Class<?> cls);
/**
* Prior to the insert perform some action. Return true if you want the
@@ -69,7 +69,7 @@ public interface BeanPersistController {
* do not want the default insert to be performed.
* </p>
*/
public boolean preInsert(BeanPersistRequest<?> request);
boolean preInsert(BeanPersistRequest<?> request);
/**
* Prior to the update perform some action. Return true if you want the
@@ -79,7 +79,7 @@ public interface BeanPersistController {
* do not want the default update to be performed.
* </p>
*/
public boolean preUpdate(BeanPersistRequest<?> request);
boolean preUpdate(BeanPersistRequest<?> request);
/**
* Prior to the delete perform some action. Return true if you want the
@@ -89,27 +89,27 @@ public interface BeanPersistController {
* do not want the default delete to be performed.
* </p>
*/
public boolean preDelete(BeanPersistRequest<?> request);
boolean preDelete(BeanPersistRequest<?> request);
/**
* Called after the insert was performed.
*/
public void postInsert(BeanPersistRequest<?> request);
void postInsert(BeanPersistRequest<?> request);
/**
* Called after the update was performed.
*/
public void postUpdate(BeanPersistRequest<?> request);
void postUpdate(BeanPersistRequest<?> request);
/**
* Called after the delete was performed.
*/
public void postDelete(BeanPersistRequest<?> request);
void postDelete(BeanPersistRequest<?> request);
/**
* Called after every each bean is fetched and loaded from the database. You
* can override this to derive some information to set to the bean.
*/
public void postLoad(Object bean, Set<String> includedProperties);
void postLoad(Object bean, Set<String> includedProperties);
}
@@ -43,7 +43,7 @@ public interface BeanPersistListener {
* Return true if this BeanPersistListener should be registered for events
* on this entity type.
*/
public boolean isRegisterFor(Class<?> cls);
boolean isRegisterFor(Class<?> cls);
/**
* Notified that a bean has been inserted locally. Return true if you want the
@@ -52,7 +52,7 @@ public interface BeanPersistListener {
* @param bean
* The bean that was inserted.
*/
public boolean inserted(Object bean);
boolean inserted(Object bean);
/**
* Notified that a bean has been updated locally. Return true if you want the
@@ -63,7 +63,7 @@ public interface BeanPersistListener {
* @param updatedProperties
* The properties that were modified by this update.
*/
public boolean updated(Object bean, Set<String> updatedProperties);
boolean updated(Object bean, Set<String> updatedProperties);
/**
* Notified that a bean has been deleted locally. Return true if you want the
@@ -72,7 +72,7 @@ public interface BeanPersistListener {
* @param bean
* The bean that was deleted.
*/
public boolean deleted(Object bean);
boolean deleted(Object bean);
/**
* Notify that a bean was inserted on another node of the cluster.
@@ -80,7 +80,7 @@ public interface BeanPersistListener {
* @param id
* the id value of the inserted bean
*/
public void remoteInsert(Object id);
void remoteInsert(Object id);
/**
* Notify that a bean was updated on another node of the cluster.
@@ -88,7 +88,7 @@ public interface BeanPersistListener {
* @param id
* the id value of the updated bean.
*/
public void remoteUpdate(Object id);
void remoteUpdate(Object id);
/**
* Notify that a bean was deleted on another node of the cluster.
@@ -96,6 +96,6 @@ public interface BeanPersistListener {
* @param id
* the id value of the deleted bean.
*/
public void remoteDelete(Object id);
void remoteDelete(Object id);
}
@@ -19,32 +19,32 @@ public interface BeanPersistRequest<T> {
/**
* Return the server processing the request.
*/
public EbeanServer getEbeanServer();
EbeanServer getEbeanServer();
/**
* Return the Transaction associated with this request.
*/
public Transaction getTransaction();
Transaction getTransaction();
/**
* For an update or delete of a partially populated bean this is the set of
* loaded properties and otherwise returns null.
*/
public Set<String> getLoadedProperties();
Set<String> getLoadedProperties();
/**
* For an update this is the set of properties that where updated.
*/
public Set<String> getUpdatedProperties();
Set<String> getUpdatedProperties();
/**
* Returns the bean being inserted updated or deleted.
*/
public T getBean();
T getBean();
/**
* Returns a map of the properties that have changed and their new and old values.
*/
public Map<String,ValuePair> getUpdatedValues();
Map<String,ValuePair> getUpdatedValues();
}
@@ -24,18 +24,18 @@ public interface BeanQueryAdapter {
* Return true if this adapter is interested in queries for the given entity
* type.
*/
public boolean isRegisterFor(Class<?> cls);
boolean isRegisterFor(Class<?> cls);
/**
* Returns an int to to control the order in which BeanQueryAdapter are
* executed when there is multiple of them registered for a given entity type
* (class).
*/
public int getExecutionOrder();
int getExecutionOrder();
/**
* Modify the associated query prior to it being executed.
*/
public void preQuery(BeanQueryRequest<?> request);
void preQuery(BeanQueryRequest<?> request);
}
@@ -12,16 +12,16 @@ public interface BeanQueryRequest<T> {
/**
* Return the server processing the request.
*/
public EbeanServer getEbeanServer();
EbeanServer getEbeanServer();
/**
* Return the Transaction associated with this request.
*/
public Transaction getTransaction();
Transaction getTransaction();
/**
* Returns the query.
*/
public Query<T> getQuery();
Query<T> getQuery();
}
@@ -10,21 +10,21 @@ public interface BulkTableEvent {
/**
* Return the name of the table that was involved.
*/
public String getTableName();
String getTableName();
/**
* Return true if rows were inserted.
*/
public boolean isInsert();
boolean isInsert();
/**
* Return true if rows were updated.
*/
public boolean isUpdate();
boolean isUpdate();
/**
* Return true if rows were deleted.
*/
public boolean isDelete();
boolean isDelete();
}
@@ -20,11 +20,11 @@ public interface BulkTableEventListener {
/**
* Return the tables that this listener is interested in.
*/
public Set<String> registeredTables();
Set<String> registeredTables();
/**
* Process the event.
*/
public void process(BulkTableEvent bulkTableEvent);
void process(BulkTableEvent bulkTableEvent);
}
@@ -16,6 +16,6 @@ public interface ServerConfigStartup {
/**
* On starting configure the ServerConfig.
*/
public void onStart(ServerConfig serverConfig);
void onStart(ServerConfig serverConfig);
}
@@ -9,10 +9,10 @@ public interface TransactionEventListener {
/**
* Called after the transaction has been committed
*/
public void postTransactionCommit(Transaction tx);
void postTransactionCommit(Transaction tx);
/**
* Called after the transaction has been rolled back
*/
public void postTransactionRollback(Transaction tx, Throwable cause);
void postTransactionRollback(Transaction tx, Throwable cause);
}
@@ -7,11 +7,11 @@ public interface MetaBeanInfo {
/**
* Collect the current query plan statistics return the non-empty statistics.
*/
public List<MetaQueryPlanStatistic> collectQueryPlanStatistics(boolean reset);
List<MetaQueryPlanStatistic> collectQueryPlanStatistics(boolean reset);
/**
* Collect the current query plan statistics return all the statistics (include query plans that haven't had query executions).
*/
public List<MetaQueryPlanStatistic> collectAllQueryPlanStatistics(boolean reset);
List<MetaQueryPlanStatistic> collectAllQueryPlanStatistics(boolean reset);
}
@@ -10,12 +10,12 @@ public interface MetaInfoManager {
/**
* Return the MetaBeanInfo for a bean type.
*/
public MetaBeanInfo getMetaBeanInfo(Class<?> beanClass);
MetaBeanInfo getMetaBeanInfo(Class<?> beanClass);
/**
* Return all the MetaBeanInfo.
*/
public List<MetaBeanInfo> getMetaBeanInfoList();
List<MetaBeanInfo> getMetaBeanInfoList();
/**
* Collect and return the query plan statistics for all the beans.
@@ -24,7 +24,7 @@ public interface MetaInfoManager {
* executions (since the last collection with reset).
* </p>
*/
public List<MetaQueryPlanStatistic> collectQueryPlanStatistics(boolean reset);
List<MetaQueryPlanStatistic> collectQueryPlanStatistics(boolean reset);
/**
* Collect and return the ObjectGraphNode statistics.
@@ -37,6 +37,6 @@ public interface MetaInfoManager {
* @param reset
* Set to true to reset the underlying statistics after collection.
*/
public List<MetaObjectGraphNodeStats> collectNodeStatistics(boolean reset);
List<MetaObjectGraphNodeStats> collectNodeStatistics(boolean reset);
}
@@ -16,26 +16,26 @@ public interface MetaObjectGraphNodeStats {
/**
* Return the ObjectGraphNode which has the origin point and relative path.
*/
public ObjectGraphNode getNode();
ObjectGraphNode getNode();
/**
* Return the startTime of statistics collection.
*/
public long getStartTime();
long getStartTime();
/**
* Return the total count of queries executed for this node.
*/
public long getCount();
long getCount();
/**
* Return the total time of queries executed for this node.
*/
public long getTotalTime();
long getTotalTime();
/**
* Return the total beans loaded by queries for this node.
*/
public long getTotalBeans();
long getTotalBeans();
}
@@ -22,12 +22,12 @@ public interface MetaQueryPlanOriginCount {
* navigation path that resulted in this query being executed.
* </p>
*/
public ObjectGraphNode getObjectGraphNode();
ObjectGraphNode getObjectGraphNode();
/**
* The number of times a query was fired for this node since the counter was
* last reset.
*/
public long getCount();
long getCount();
}
@@ -12,27 +12,27 @@ public interface MetaQueryPlanStatistic {
/**
* Return the bean type this query plan is for.
*/
public Class<?> getBeanType();
Class<?> getBeanType();
/**
* Return true if this query plan was tuned by Autofetch.
*/
public boolean isAutofetchTuned();
boolean isAutofetchTuned();
/**
* Return a string representation of the query plan hash.
*/
public String getQueryPlanHash();
String getQueryPlanHash();
/**
* Return the sql executed.
*/
public String getSql();
String getSql();
/**
* Return the total number of queries executed.
*/
public long getExecutionCount();
long getExecutionCount();
/**
* Return the total number of beans loaded by the queries.
@@ -40,27 +40,27 @@ public interface MetaQueryPlanStatistic {
* This excludes background fetching.
* </p>
*/
public long getTotalLoadedBeans();
long getTotalLoadedBeans();
/**
* Return the total time taken by executions of this query.
*/
public long getTotalTimeMicros();
long getTotalTimeMicros();
/**
* Return the max execution time for this query.
*/
public long getMaxTimeMicros();
long getMaxTimeMicros();
/**
* Return the time collection started (or was last reset).
*/
public long getCollectionStart();
long getCollectionStart();
/**
* Return the time of the last query executed using this plan.
*/
public long getLastQueryTime();
long getLastQueryTime();
/**
* Return the average query execution time in microseconds.
@@ -68,7 +68,7 @@ public interface MetaQueryPlanStatistic {
* This excludes background fetching.
* </p>
*/
public long getAvgTimeMicros();
long getAvgTimeMicros();
/**
* Return the average number of bean loaded per query.
@@ -76,7 +76,7 @@ public interface MetaQueryPlanStatistic {
* This excludes background fetching.
* </p>
*/
public long getAvgLoadedBeans();
long getAvgLoadedBeans();
/**
* Return the 'origin' points and paths that resulted in the query being
@@ -86,6 +86,6 @@ public interface MetaQueryPlanStatistic {
* This includes direct and lazy loading paths.
* </p>
*/
public List<MetaQueryPlanOriginCount> getOrigins();
List<MetaQueryPlanOriginCount> getOrigins();
}
@@ -13,5 +13,5 @@ public interface StringFormatter {
/**
* Convert an Object value into a String value.
*/
public String format(Object value);
String format(Object value);
}
@@ -13,5 +13,5 @@ public interface StringParser {
/**
* Convert a String value into an Object value.
*/
public Object parse(String value);
Object parse(String value);
}
@@ -23,7 +23,7 @@ public interface CsvCallback<T> {
* size etc.
* </p>
*/
public void begin(EbeanServer server);
void begin(EbeanServer server);
/**
* Read the header row.
@@ -35,14 +35,14 @@ public interface CsvCallback<T> {
* @param line
* the header line content.
*/
public void readHeader(String[] line);
void readHeader(String[] line);
/**
* Check that the row should be processed - return true to process the row or
* false to ignore the row. Gives ability to handle bad data... empty rows etc
* and ignore it rather than fail.
*/
public boolean processLine(int row, String[] line);
boolean processLine(int row, String[] line);
/**
* Called for each bean after it has been loaded from the CSV content.
@@ -62,7 +62,7 @@ public interface CsvCallback<T> {
* @param bean
* the entity bean after it has been loaded from the csv content
*/
public void processBean(int row, String[] line, T bean);
void processBean(int row, String[] line, T bean);
/**
* The processing has ended successfully.
@@ -70,7 +70,7 @@ public interface CsvCallback<T> {
* Typically the callback will commit the transaction.
* </p>
*/
public void end(int row);
void end(int row);
/**
* The processing has ended due to an error.
@@ -84,6 +84,6 @@ public interface CsvCallback<T> {
* @param e
* the error that occured
*/
public void endWithError(int row, Exception e);
void endWithError(int row, Exception e);
}
@@ -48,22 +48,22 @@ public interface CsvReader<T> {
/**
* Explicitly set the default Locale.
*/
public void setDefaultLocale(Locale defaultLocale);
void setDefaultLocale(Locale defaultLocale);
/**
* Set the default format to use for Time types.
*/
public void setDefaultTimeFormat(String defaultTimeFormat);
void setDefaultTimeFormat(String defaultTimeFormat);
/**
* Set the default format to use for Date types.
*/
public void setDefaultDateFormat(String defaultDateFormat);
void setDefaultDateFormat(String defaultDateFormat);
/**
* Set the default format to use for Timestamp types.
*/
public void setDefaultTimestampFormat(String defaultTimestampFormat);
void setDefaultTimestampFormat(String defaultTimestampFormat);
/**
* Set the batch size for using JDBC statement batching.
@@ -72,7 +72,7 @@ public interface CsvReader<T> {
* JDBC statement batching.
* </p>
*/
public void setPersistBatchSize(int persistBatchSize);
void setPersistBatchSize(int persistBatchSize);
/**
* Set to true if there is a header row that should be ignored.
@@ -84,7 +84,7 @@ public interface CsvReader<T> {
* add the properties yourself.
* </p>
*/
public void setHasHeader(boolean hasHeader, boolean addPropertiesFromHeader);
void setHasHeader(boolean hasHeader, boolean addPropertiesFromHeader);
/**
* Same as setHasHeader(true,true);
@@ -93,7 +93,7 @@ public interface CsvReader<T> {
* default formats for time, date and datetime types.
* </p>
*/
public void setAddPropertiesFromHeader();
void setAddPropertiesFromHeader();
/**
* Same as setHasHeader(true, false);
@@ -101,7 +101,7 @@ public interface CsvReader<T> {
* This indicates that there is a header but that it should be ignored.
* </p>
*/
public void setIgnoreHeader();
void setIgnoreHeader();
/**
* Set the frequency with which a INFO message will be logged showing the
@@ -110,12 +110,12 @@ public interface CsvReader<T> {
* If this is not set then no INFO messages will be logged.
* </p>
*/
public void setLogInfoFrequency(int logInfoFrequency);
void setLogInfoFrequency(int logInfoFrequency);
/**
* Ignore the next column of data.
*/
public void addIgnore();
void addIgnore();
/**
* Define the property which will be loaded from the next column of data.
@@ -124,27 +124,27 @@ public interface CsvReader<T> {
* String to object conversion automatically.
* </p>
*/
public void addProperty(String propertyName);
void addProperty(String propertyName);
/**
* Define the next property and use a custom StringParser to convert the
* string content into the appropriate type for the property.
*/
public void addProperty(String propertyName, StringParser parser);
void addProperty(String propertyName, StringParser parser);
/**
* Add a property with a custom Date/Time/Timestamp format using the default
* Locale. This will convert the string into the appropriate java type for the
* given property (Date, Calendar, SQL Date, Time, Timestamp, JODA etc).
*/
public void addDateTime(String propertyName, String dateTimeFormat);
void addDateTime(String propertyName, String dateTimeFormat);
/**
* Add a property with a custom Date/Time/Timestamp format. This will convert
* the string into the appropriate java type for the given property (Date,
* Calendar, SQL Date, Time, Timestamp, JODA etc).
*/
public void addDateTime(String propertyName, String dateTimeFormat, Locale locale);
void addDateTime(String propertyName, String dateTimeFormat, Locale locale);
/**
* Automatically create a transaction if required to process all the CSV
@@ -155,7 +155,7 @@ public interface CsvReader<T> {
* processing. This will also set the persistBatchSize on the transaction.
* </p>
*/
public void process(Reader reader) throws Exception;
void process(Reader reader) throws Exception;
/**
* Process the CSV content passing the bean to the CsvCallback after each row.
@@ -168,6 +168,6 @@ public interface CsvReader<T> {
* create your own transaction and save the bean(s) yourself.
* </p>
*/
public void process(Reader reader, CsvCallback<T> callback) throws Exception;
void process(Reader reader, CsvCallback<T> callback) throws Exception;
}
@@ -19,42 +19,42 @@ public interface JsonContext {
*
* @throws JsonIOException When IOException occurs
*/
public <T> T toBean(Class<T> rootType, String json) throws JsonIOException;
<T> T toBean(Class<T> rootType, String json) throws JsonIOException;
/**
* Convert json reader input into a Bean of a specific type.
*
* @throws JsonIOException When IOException occurs
*/
public <T> T toBean(Class<T> rootType, Reader json) throws JsonIOException;
<T> T toBean(Class<T> rootType, Reader json) throws JsonIOException;
/**
* Convert json parser input into a Bean of a specific type.
*
* @throws JsonIOException When IOException occurs
*/
public <T> T toBean(Class<T> cls, JsonParser parser) throws JsonIOException;
<T> T toBean(Class<T> cls, JsonParser parser) throws JsonIOException;
/**
* Convert json string input into a list of beans of a specific type.
*
* @throws JsonIOException When IOException occurs
*/
public <T> List<T> toList(Class<T> rootType, String json) throws JsonIOException;
<T> List<T> toList(Class<T> rootType, String json) throws JsonIOException;
/**
* Convert json reader input into a list of beans of a specific type.
*
* @throws JsonIOException When IOException occurs
*/
public <T> List<T> toList(Class<T> rootType, Reader json) throws JsonIOException;
<T> List<T> toList(Class<T> rootType, Reader json) throws JsonIOException;
/**
* Convert json parser input into a list of beans of a specific type.
*
* @throws JsonIOException When IOException occurs
*/
public <T> List<T> toList(Class<T> cls, JsonParser src) throws JsonIOException;
<T> List<T> toList(Class<T> cls, JsonParser src) throws JsonIOException;
/**
* Use the genericType to determine if this should be converted into a List or
@@ -62,7 +62,7 @@ public interface JsonContext {
*
* @throws JsonIOException When IOException occurs
*/
public Object toObject(Type genericType, Reader json) throws JsonIOException;
Object toObject(Type genericType, Reader json) throws JsonIOException;
/**
* Use the genericType to determine if this should be converted into a List or
@@ -70,7 +70,7 @@ public interface JsonContext {
*
* @throws JsonIOException When IOException occurs
*/
public Object toObject(Type genericType, String json) throws JsonIOException;
Object toObject(Type genericType, String json) throws JsonIOException;
/**
* Use the genericType to determine if this should be converted into a List or
@@ -78,45 +78,45 @@ public interface JsonContext {
*
* @throws JsonIOException When IOException occurs
*/
public Object toObject(Type genericType, JsonParser jsonParser) throws JsonIOException;
Object toObject(Type genericType, JsonParser jsonParser) throws JsonIOException;
/**
* Return the bean or collection as JSON string.
*
* @throws JsonIOException When IOException occurs
*/
public String toJson(Object value) throws JsonIOException;
String toJson(Object value) throws JsonIOException;
/**
* Write the bean or collection in JSON format to the writer.
*
* @throws JsonIOException When IOException occurs
*/
public void toJson(Object value, Writer writer) throws JsonIOException;
void toJson(Object value, Writer writer) throws JsonIOException;
/**
* Write the bean or collection to the JsonGenerator.
*
* @throws JsonIOException When IOException occurs
*/
public void toJson(Object value, JsonGenerator generator) throws JsonIOException;
void toJson(Object value, JsonGenerator generator) throws JsonIOException;
/**
* Return the bean or collection as JSON string using PathProperties.
*
* @throws JsonIOException When IOException occurs
*/
public String toJson(Object value, PathProperties pathProperties) throws JsonIOException;
String toJson(Object value, PathProperties pathProperties) throws JsonIOException;
/**
* Write the bean or collection as json to the writer using the PathProperties.
*/
public void toJson(Object value, Writer writer, PathProperties pathProperties) throws JsonIOException;
void toJson(Object value, Writer writer, PathProperties pathProperties) throws JsonIOException;
/**
* Write the bean or collection to the JsonGenerator using the PathProperties.
*/
public void toJson(Object value, JsonGenerator generator, PathProperties pathProperties) throws JsonIOException;
void toJson(Object value, JsonGenerator generator, PathProperties pathProperties) throws JsonIOException;
/**
* Deprecated in favour of using PathProperties by itself.
@@ -124,7 +124,7 @@ public interface JsonContext {
*
* @deprecated
*/
public void toJson(Object value, JsonGenerator generator, JsonWriteOptions options) throws JsonIOException;
void toJson(Object value, JsonGenerator generator, JsonWriteOptions options) throws JsonIOException;
/**
* Deprecated in favour of using PathProperties by itself.
@@ -133,7 +133,7 @@ public interface JsonContext {
* @throws JsonIOException When IOException occurs
* @deprecated
*/
public void toJson(Object value, Writer writer, JsonWriteOptions options) throws JsonIOException;
void toJson(Object value, Writer writer, JsonWriteOptions options) throws JsonIOException;
/**
* Deprecated in favour of using PathProperties by itself.
@@ -142,25 +142,25 @@ public interface JsonContext {
* @throws JsonIOException When IOException occurs
* @deprecated
*/
public String toJson(Object value, JsonWriteOptions options) throws JsonIOException;
String toJson(Object value, JsonWriteOptions options) throws JsonIOException;
/**
* Return true if the type is known as an Entity bean or a List Set or
* Map of entity beans.
*/
public boolean isSupportedType(Type genericType);
boolean isSupportedType(Type genericType);
/**
* Create and return a new JsonGenerator for the given writer.
*
* @throws JsonIOException When IOException occurs
*/
public JsonGenerator createGenerator(Writer writer) throws JsonIOException;
JsonGenerator createGenerator(Writer writer) throws JsonIOException;
/**
* Create and return a new JsonParser for the given reader.
*
* @throws JsonIOException When IOException occurs
*/
public JsonParser createParser(Reader reader) throws JsonIOException;
JsonParser createParser(Reader reader) throws JsonIOException;
}
@@ -3,19 +3,34 @@ package com.avaje.tests.transaction;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.Transaction;
import com.avaje.ebean.TxIsolation;
import org.junit.Test;
import javax.persistence.PersistenceException;
import java.sql.Connection;
import static org.junit.Assert.assertEquals;
public class TestBeginTransactionWithExisting extends BaseTestCase {
@Test
public void testTransactionIsoLevels() {
assertEquals(Transaction.READ_COMMITTED, Connection.TRANSACTION_READ_COMMITTED);
assertEquals(Transaction.READ_UNCOMMITTED, Connection.TRANSACTION_READ_UNCOMMITTED);
assertEquals(Transaction.REPEATABLE_READ, Connection.TRANSACTION_REPEATABLE_READ);
assertEquals(Transaction.SERIALIZABLE, Connection.TRANSACTION_SERIALIZABLE);
}
@Test(expected = PersistenceException.class)
public void test() {
assertEquals(Transaction.READ_COMMITTED, Connection.TRANSACTION_READ_COMMITTED);
Transaction txn = Ebean.beginTransaction();
try {
Ebean.beginTransaction();
Ebean.beginTransaction(TxIsolation.READ_COMMITED);
} finally {
txn.end();