简体   繁体   中英

How do I override ActiveModel type processing in Rails (JRuby)

I'm trying to create a rails model around an oracle table that has a column "SESSION_XML" using Oracle's XMLTYPE. Whenever I attempt to use the model to get data from the db, the connection adapter responds with:

SELECT "ZC_SESSION_DATA".* FROM "ZC_SESSION_DATA" WHERE ROWNUM <= 1
ActiveRecord::StatementInvalid: Java::JavaLang::NoClassDefFoundError: oracle/xdb/XMLType:SELECT  "ZC_SESSION_DATA".* FROM "ZC_SESSION_DATA"  WHERE ROWNUM <= 1
from oracle.jdbc.oracore.OracleTypeADT.applyTDSpatches(OracleTypeADT.java:1081)

It seems clear to me that Java (I'm using Rails on top of JRuby) is complaining that it doesn't have a type with which to parse the XMLTYPE column, so my question is this: How can I force rails to interpret the XMLTYPE as a flat string.

I'm fine with needing to parse the XML myself, but how do I get the adapter to stop trying to parse it?

This is an Oracle problem, not really an ActiveRecord problem:

https://community.oracle.com/thread/485754?start=0&tstart=0

TL;DR there's a jar that isn't being loaded that defines XMLType.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM