mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-13 21:01:01 +08:00
#648872 : added simplifications
This commit is contained in:
parent
59abe7ab62
commit
606080418b
@ -100,34 +100,33 @@ public class Configuration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the given Type
|
||||
* Register the given Type to be used
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public void register(Type<?> type) {
|
||||
public void registerCustomType(Type<?> type) {
|
||||
javaTypeMapping.register(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the java type for the given JDBC type
|
||||
*
|
||||
* @param jdbcType
|
||||
* @param javaType
|
||||
*/
|
||||
public void setType(int jdbcType, Class<?> javaType) {
|
||||
jdbcTypeMapping.register(jdbcType, javaType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the java type for the given table and column
|
||||
* Register the given Type for the given table and column
|
||||
*
|
||||
* @param table
|
||||
* @param column
|
||||
* @param type
|
||||
*/
|
||||
public void setType(String table, String column, Type<?> type) {
|
||||
public void registerCustomType(String table, String column, Type<?> type) {
|
||||
javaTypeMapping.setType(table, column, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the given java type to be used for the given JDBC type
|
||||
*
|
||||
* @param jdbcType
|
||||
* @param javaType
|
||||
*/
|
||||
public void setJavaType(int jdbcType, Class<?> javaType) {
|
||||
jdbcTypeMapping.register(jdbcType, javaType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,18 +22,18 @@ public class ConfigurationTest {
|
||||
@Test
|
||||
public void Various(){
|
||||
Configuration configuration = new Configuration(new H2Templates());
|
||||
configuration.setType(Types.DATE, java.util.Date.class);
|
||||
configuration.setType("person", "secureId", new EncryptedString());
|
||||
configuration.setType("person", "gender", new EnumByNameType<Gender>(Gender.class));
|
||||
configuration.register(new StringType());
|
||||
configuration.setJavaType(Types.DATE, java.util.Date.class);
|
||||
configuration.registerCustomType("person", "secureId", new EncryptedString());
|
||||
configuration.registerCustomType("person", "gender", new EnumByNameType<Gender>(Gender.class));
|
||||
configuration.registerCustomType(new StringType());
|
||||
assertEquals(Gender.class, configuration.getJavaType(java.sql.Types.VARCHAR, "person", "gender"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Custom_Type(){
|
||||
Configuration configuration = new Configuration(new H2Templates());
|
||||
configuration.setType(Types.BLOB, InputStream.class);
|
||||
configuration.register(new InputStreamType());
|
||||
configuration.setJavaType(Types.BLOB, InputStream.class);
|
||||
configuration.registerCustomType(new InputStreamType());
|
||||
assertEquals(InputStream.class, configuration.getJavaType(Types.BLOB, "", ""));
|
||||
}
|
||||
|
||||
|
||||
@ -43,10 +43,10 @@ public class CustomTypesTest extends AbstractJDBCTest{
|
||||
|
||||
// create configuration
|
||||
configuration = new Configuration(new HSQLDBTemplates());
|
||||
configuration.setType(Types.DATE, java.util.Date.class);
|
||||
configuration.setType("person", "secureId", new EncryptedString());
|
||||
configuration.setType("person", "gender", new EnumByNameType<Gender>(Gender.class));
|
||||
configuration.register(new StringType());
|
||||
configuration.setJavaType(Types.DATE, java.util.Date.class);
|
||||
configuration.registerCustomType("person", "secureId", new EncryptedString());
|
||||
configuration.registerCustomType("person", "gender", new EnumByNameType<Gender>(Gender.class));
|
||||
configuration.registerCustomType(new StringType());
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user