<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Oracle User Type Mappings
</h3>
<span style="margin-bottom: 10px;">
    reply from <a href="http://community.jboss.org/people/ThisRegistrationSucks">Bob Frapples</a> in <i>Datasource Configuration</i> - <a href="http://community.jboss.org/message/553503#553503">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Here is the relevant code:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>From myDS-ds.xml</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{code:xml}</p><p>&lt;datasources&gt;<br/>&#160; &lt;local-tx-datasource&gt;<br/>&#160;&#160;&#160; &lt;jndi-name&gt;jdbc/MyDS&lt;/jndi-name&gt;<br/>&#160;&#160;&#160; &lt;use-java-context&gt;false&lt;/use-java-context&gt;<br/>&#160;&#160;&#160; &lt;connection-url&gt;jdbc:oracle:thin:@1.1.1.1:1521:orcl&lt;/connection-url&gt;<br/>&#160;&#160;&#160; &lt;driver-class&gt;oracle.jdbc.OracleDriver&lt;/driver-class&gt;<br/>&#160;&#160;&#160; &lt;user-name&gt;user&lt;/user-name&gt;<br/>&#160;&#160;&#160; &lt;password&gt;pass&lt;/password&gt;<br/>&#160;&#160;&#160; &lt;!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool --&gt;<br/>&#160;&#160;&#160; &lt;!--valid-connection-checker-class-name&gt;org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker&lt;/valid-connection-checker-class-name--&gt;<br/>&#160;&#160;&#160; &lt;!-- Checks the Oracle error codes and messages for fatal errors --&gt;<br/>&#160;&#160;&#160; &lt;exception-sorter-class-name&gt;org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter&lt;/exception-sorter-class-name&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!-- sql to call when connection is created<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;new-connection-sql&gt;some arbitrary sql&lt;/new-connection-sql&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; --&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered --&gt;<br/>&#160;&#160;&#160; &lt;check-valid-connection-sql&gt;SELECT * FROM DUAL&lt;/check-valid-connection-sql&gt;</p><p>&#160;&#160;&#160; &lt;!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) --&gt;<br/>&#160;&#160;&#160; &lt;metadata&gt;<br/>&#160;&#160;&#160;&#160;&#160;&#160; &lt;type-mapping&gt;Oracle9i&lt;/type-mapping&gt;<br/>&#160;&#160;&#160; &lt;/metadata&gt;<br/>&#160; &lt;/local-tx-datasource&gt;</p><p>&lt;/datasources&gt;</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>From application-context.xml</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{code:xml}</p><p><span style="color: #008080; font-size: 10pt;"><span style="color: #008080; font-size: 10pt;"><p align="left">&lt;<span style="color: #3f7f7f; font-size: 10pt; ">bean</span><span style="font-size: 10pt;"> </span><span style="color: #7f007f; font-size: 10pt; ">id</span><span style="font-size: 10pt;">=</span><em><span style="color: #2a00ff; font-size: 10pt; ">"dataSource"</span><span style="font-size: 10pt;"> </span><span style="color: #7f007f; font-size: 10pt; ">class</span><span style="font-size: 10pt;">=</span><em><span style="color: #2a00ff; font-size: 10pt; ">"org.springframework.jndi.JndiObjectFactoryBean"</span><span style="color: #008080; font-size: 10pt; ">&gt;</span><span style="font-size: 10pt;"><p align="left"><span style="color: #008080; font-size: 10pt; ">&#160; &lt;</span><span style="color: #3f7f7f; font-size: 10pt; ">property</span><span style="font-size: 10pt;"> </span><span style="color: #7f007f; font-size: 10pt; ">name</span><span style="font-size: 10pt;">=</span><em><span style="color: #2a00ff; font-size: 10pt; ">"jndiName"</span><span style="font-size: 10pt;"> </span><span style="color: #7f007f; font-size: 10pt; ">value</span><span style="font-size: 10pt;">=</span><em><span style="color: #2a00ff; font-size: 10pt; ">"jdbc/MyDS"</span><span style="font-size: 10pt;"> </span><span style="color: #008080; font-size: 10pt; ">/&gt;</span><span style="font-size: 10pt;">&#160; <p align="left"><span style="color: #008080; font-size: 10pt; ">&#160; &lt;</span><span style="color: #3f7f7f; font-size: 10pt; ">property</span><span style="font-size: 10pt;"> </span><span style="color: #7f007f; font-size: 10pt; ">name</span><span style="font-size: 10pt;">=</span><em><span style="color: #2a00ff; font-size: 10pt; ">"expectedType"</span><span style="font-size: 10pt;"> </span><span style="color: #7f007f; font-size: 10pt; ">value</span><span style="font-size: 10pt;">=</span><em><span style="color: #2a00ff; font-size: 10pt; ">"javax.sql.DataSource"</span><span style="color: #008080; font-size: 10pt; ">/&gt;</span><span style="font-size: 10pt;"><p><span style="color: #008080; font-size: 10pt; ">&lt;/</span><span style="color: #3f7f7f; font-size: 10pt; ">bean</span><span style="color: #008080; font-size: 10pt; ">&gt;</span></p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>From AppContext.java</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{code}</p><p>((DataSource)ctx.getBean("dataSource")).getConnection.setTypeMap(MyMappings.TYPE_MAP);</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><span style=": ; font-size: 2; font-color: #008080; "><em><em style=": ; font-size: 2; "><em><em style=": ; font-size: 2; "><em><em style=": ; font-size: 2; "><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></em></em></em></em></em></em></span></span></em></em><span style=": ; font-size: 2; font-color: #008080; "><em><em style=": ; font-size: 2; "><em><em style=": ; font-size: 2; "><em><em><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></em></em></em></em></em></em></span></p></span></em></em><span style=": ; font-size: 2; font-color: #008080; "><em><em style=": ; font-size: 2; "><em><em><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></em></em></em></em></span></p></span></em></em><span style=": ; font-size: 2; font-color: #008080; "><em><em><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></em></em></span></p></span><span style="font-color: #008080; font-size: 2; "><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></span></span><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>From MyMappings.java</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{code}</p></p><p align="left"><strong style="color: #7f0055; font-size: 10pt; "><span style="color: #7f0055; font-size: 10pt;"><strong style=": ; font-size: 2; font-color: #7f0055; "><p><p><p align="left">public</p></p></p></strong></span><strong style=": ; font-size: 2; font-color: #7f0055; "><p><p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></p></p></strong></strong></p><p><p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><span style="color: #000000; font-size: 10pt;"> </span><strong style=": ; color: #7f0055; font-size: 10pt; ">static</strong><span style="color: #000000; font-size: 10pt;"> </span><strong style=": ; color: #7f0055; font-size: 10pt; ">final</strong><span style="color: #000000; font-size: 10pt;"> Map&lt;String, Class&lt;?&gt;&gt; </span><em style=": ; color: #0000c0; font-size: 10pt; ">TYPE_MAP</em><span style="color: #000000; font-size: 10pt;"> = </span><strong style=": ; color: #7f0055; font-size: 10pt; ">new</strong><p align="left"><span style="font-size: 10pt;"><span style="color: #000000;"> HashMap&lt;String, Class&lt;?&gt;&gt;();</span><span style="font-size: 2; "><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></span></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><strong style=": ; color: #7f0055; font-size: 10pt; ">static</strong><p><span style="font-size: 10pt;"> {</span></p></p></p><p><span style="color: #0000c0; font-size: 10pt;"><span style=": ; color: #0000c0; font-size: 2; font-color: #0000c0; "><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></span><span style="font-color: #0000c0; font-size: 2; "><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></span></span><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></p><p><p><em><span style="color: #0000c0; font-size: 10pt;"><span style="color: #0000c0; font-size: 10pt;"><em style=": ; font-size: 2; font-color: #0000c0; "><p>TYPE_MAP</p></em></span><em style=": ; font-size: 2; font-color: #0000c0; "><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></em></span><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><span style="color: #000000; font-size: 10pt;">.put(User.</span><em style=": ; color: #0000c0; font-size: 10pt; ">SQLTypeName</em><span style="color: #000000; font-size: 10pt;">, User.</span><strong style=": ; color: #7f0055; font-size: 10pt; ">class</strong><p><span style="color: #000000; font-size: 10pt; ">);</span></p></em></p></p><p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{code}</p></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Here is the stack trace:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{code}</p><p>2010-07-20 08:29:52,715 ERROR [STDERR] (http-127.0.0.1-8080-1) java.lang.ClassCastException: oracle.sql.STRUCT cannot be cast to editor.hibernate.model.User<br/>2010-07-20 08:29:52,715 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at editor.hibernate.dao.function.FnGetUserByName.execute(FnGetUserByName.java:33)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at editor.service.UserService.getUser(UserService.java:55)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at editor.service.UserService.userLogin(UserService.java:66)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at editor.controller.LoginController.login(LoginController.java:42)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at java.lang.reflect.Method.invoke(Method.java:597)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.springframework.web.servlet.mvc.multiaction.MultiActionController.invokeNamedMethod(MultiActionController.java:471)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.springframework.web.servlet.mvc.multiaction.MultiActionController.handleRequestInternal(MultiActionController.java:408)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)<br/>2010-07-20 08:29:52,730 ERROR [STDERR] (http-127.0.0.1-8080-1)&#160; at java.lang.Thread.run(Thread.java:619)</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Sorry for the bad formatting, I'm not used to this forum interface.&#160; Hope it helps.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/553503#553503">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Datasource Configuration at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2077">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>