From: <leg...@at...> - 2003-10-23 05:45:15
|
Message: The following issue has been closed. Resolver: Gavin King Date: Wed, 22 Oct 2003 7:42 PM There has been no real demand for this and it is easily handled as a user type. So lets not bloat Hibernate. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-30 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-30 Summary: SqlData type Type: Patch Status: Closed Priority: Major Resolution: WON'T FIX Project: Hibernate2 Assignee: Gavin King Reporter: Max Rydahl Andersen Created: Sat, 3 May 2003 10:17 AM Updated: Wed, 22 Oct 2003 7:42 PM Description: SqlData type We have some Oracle objects and need to read/write its to database. We have java classes that implements java.sql.SqlData interface but Hibernate can't map SQL object types to java (perhaps I simple don't know how to do it). I wrote SqlDataType class which can do it for me and changed TypeFactory for produces SqlDataType for classes which instantiate SqlData interface. All work nice but I can't use fields of that classes in Query. It will be nice to see it in future release. Here is my implementation of SqlDataType: -------------------------------- package net.sf.hibernate.type; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; public class SqlDataType extends PrimitiveType { protected Class persistentClass; public SqlDataType(Class persistentClass) { this.persistentClass = persistentClass; } public Object get(ResultSet rs, String name) throws SQLException { return rs.getObject(name); } public Class primitiveClass() { return persistentClass; } public Class getReturnedClass() { return persistentClass; } public void set(PreparedStatement st, Object value, int index) throws SQLException { if (value == null) st.setNull(index, sqlType()); else st.setObject(index, value); } public int sqlType() { return Types.JAVA_OBJECT; } public String getName() { return persistentClass.getName(); } public String objectToSQLString(Object value) throws Exception { return value.toString(); } } ------------ Here changes in hueristicType method of TypeFactory class else if ( SQLData.class.isAssignableFrom(typeClass) ) { type = new SqlDataType(typeClass); } With best regards. Dmitry M.Ivlev http://sourceforge.net/tracker/index.php?func=detail&aid=705454&group_id=40712&atid=428711 --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |