HHH-5283 - Add BasicType handling of java.net.URL
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@20025 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
537f135ee1
commit
1252346e76
|
@ -24,7 +24,7 @@
|
||||||
package org.hibernate.type;
|
package org.hibernate.type;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.URL;
|
import java.net.Socket;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -34,6 +34,7 @@ import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.engine.SessionImplementor;
|
import org.hibernate.engine.SessionImplementor;
|
||||||
|
import org.hibernate.type.descriptor.java.StringTypeDescriptor;
|
||||||
import org.hibernate.type.descriptor.java.UrlTypeDescriptor;
|
import org.hibernate.type.descriptor.java.UrlTypeDescriptor;
|
||||||
import org.hibernate.type.descriptor.sql.VarcharTypeDescriptor;
|
import org.hibernate.type.descriptor.sql.VarcharTypeDescriptor;
|
||||||
import org.hibernate.usertype.CompositeUserType;
|
import org.hibernate.usertype.CompositeUserType;
|
||||||
|
@ -66,13 +67,13 @@ public class BasicTypeRegistryTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExpanding() {
|
public void testExpanding() {
|
||||||
BasicType type = registry.getRegisteredType( URL.class.getName() );
|
BasicType type = registry.getRegisteredType( SomeNoopType.INSTANCE.getName() );
|
||||||
assertNull( type );
|
assertNull( type );
|
||||||
|
|
||||||
registry.register( UrlType.INSTANCE );
|
registry.register( SomeNoopType.INSTANCE );
|
||||||
type = registry.getRegisteredType( URL.class.getName() );
|
type = registry.getRegisteredType( SomeNoopType.INSTANCE.getName() );
|
||||||
assertNotNull( type );
|
assertNotNull( type );
|
||||||
assertSame( UrlType.INSTANCE, type );
|
assertSame( SomeNoopType.INSTANCE, type );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRegisteringUserTypes() {
|
public void testRegisteringUserTypes() {
|
||||||
|
@ -96,20 +97,20 @@ public class BasicTypeRegistryTest extends TestCase {
|
||||||
assertEquals( CustomType.class, type.getClass() );
|
assertEquals( CustomType.class, type.getClass() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class UrlType extends AbstractSingleColumnStandardBasicType<URL> {
|
public static class SomeNoopType extends AbstractSingleColumnStandardBasicType<String> {
|
||||||
public static final UrlType INSTANCE = new UrlType();
|
public static final SomeNoopType INSTANCE = new SomeNoopType();
|
||||||
|
|
||||||
public UrlType() {
|
public SomeNoopType() {
|
||||||
super( VarcharTypeDescriptor.INSTANCE, UrlTypeDescriptor.INSTANCE );
|
super( VarcharTypeDescriptor.INSTANCE, StringTypeDescriptor.INSTANCE );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "url";
|
return "noop";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean registerUnderJavaType() {
|
protected boolean registerUnderJavaType() {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue