-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: ORACLE LONG and joined-subclass problem
PostPosted: Fri Mar 05, 2004 9:05 am 
Newbie

Joined: Fri Mar 05, 2004 8:55 am
Posts: 19
-hibernate 2.1.2 (DEBUG level)
-oracle 8i

sorry for my poor English...

Hello,

I have a problem with Oracle LONG column and joined-subclass:

----------------------------------
DATABASE script
----------------------------------
alter table DOSSIER_WEB drop constraint FK3FB03BA0217F38D0;
drop table DOSSIER cascade constraints;
drop table DOSSIER_WEB cascade constraints;
create table DOSSIER (
ID NUMBER(10,0) not null,
LABEL LONG,
primary key (ID)
);
create table DOSSIER_WEB (
PARENT_ID NUMBER(10,0) not null,
PK NUMBER(10,0),
MOT VARCHAR2(250),
primary key (PARENT_ID)
);
alter table DOSSIER_WEB add constraint FK3FB03BA0217F38D0 foreign key (PARENT_ID) references DOSSIER;


insert into DOSSIER values(1,'le label dans le LONG');
insert into DOSSIER_WEB values(1,1,'label2');

insert into DOSSIER values(2,'1 le label dans le LONG');
insert into DOSSIER_WEB values(2,2,'1 label2');

----------------------------------
MAPPING
----------------------------------
<class name="Dossier" table="DOSSIER">
<id column="ID" name="id" type="int" length="21" unsaved-value="0">
<generator class="assigned"/>
</id>
<property name="label" column="LABEL" type="string"/>

<joined-subclass name="DossierWeb" table="DOSSIER_WEB">
<key column="PARENT_ID"/>
<property name="pk" column="PK" length="21" type="integer"/>
<property name="mot" column="MOT" length="250" type="string"/>
</joined-subclass>
</class>
----------------------------------
OBJECT
----------------------------------
public class Dossier {

protected int id=0;
private String label;

public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
}
public class DossierWeb extends Dossier{

private int pk=0;
private String mot;

public String getMot() {
return mot;
}
public void setMot(String mot) {
this.mot = mot;
}
public int getPk() {
return pk;
}
public void setPk(int pk) {
this.pk = pk;
}
}
----------------------------------
THE PROBLEM DESCRIPTION
----------------------------------
Query q = session.createQuery("from Dossier");// no problemo with "from DossierWeb" !!!!!!
List results = q.list();

the trace:

05 mars 13:58:29 INFO [main] net.sf.hibernate.cfg.Environment - Hibernate 2.1.2
05 mars 13:58:29 INFO [main] net.sf.hibernate.cfg.Environment - hibernate.properties not found
05 mars 13:58:29 INFO [main] net.sf.hibernate.cfg.Environment - using CGLIB reflection optimizer
05 mars 13:58:29 INFO [main] net.sf.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
05 mars 13:58:29 INFO [main] net.sf.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
05 mars 13:58:29 DEBUG [main] net.sf.hibernate.util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibern ... on-2.0.dtd in classpath under net/sf/hibernate/
05 mars 13:58:29 DEBUG [main] net.sf.hibernate.util.DTDEntityResolver - found http://hibernate.sourceforge.net/hibern ... on-2.0.dtd in classpath
05 mars 13:58:29 DEBUG [main] net.sf.hibernate.cfg.Configuration - show_sql=true
05 mars 13:58:29 DEBUG [main] net.sf.hibernate.cfg.Configuration - connection.url=jdbc:oracle:thin:@serveur:1521:marco
05 mars 13:58:29 DEBUG [main] net.sf.hibernate.cfg.Configuration - connection.driver_class=oracle.jdbc.driver.OracleDriver
05 mars 13:58:29 DEBUG [main] net.sf.hibernate.cfg.Configuration - connection.username=david
05 mars 13:58:29 DEBUG [main] net.sf.hibernate.cfg.Configuration - connection.password=marcomp
05 mars 13:58:29 DEBUG [main] net.sf.hibernate.cfg.Configuration - dialect=net.sf.hibernate.dialect.OracleDialect
05 mars 13:58:29 DEBUG [main] net.sf.hibernate.cfg.Configuration - null<-org.dom4j.tree.DefaultAttribute@10da5eb [Attribute: name resource value "Dossier.hbm.xml"]
05 mars 13:58:29 INFO [main] net.sf.hibernate.cfg.Configuration - Mapping resource: Dossier.hbm.xml
05 mars 13:58:29 DEBUG [main] net.sf.hibernate.util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath under net/sf/hibernate/
05 mars 13:58:29 DEBUG [main] net.sf.hibernate.util.DTDEntityResolver - found http://hibernate.sourceforge.net/hibern ... ng-2.0.dtd in classpath
05 mars 13:58:29 INFO [main] net.sf.hibernate.cfg.Binder - Mapping class: Dossier -> DOSSIER
05 mars 13:58:30 DEBUG [main] net.sf.hibernate.cfg.Binder - Mapped property: id -> ID, type: integer
05 mars 13:58:30 DEBUG [main] net.sf.hibernate.cfg.Binder - Mapped property: label -> LABEL, type: string
05 mars 13:58:30 INFO [main] net.sf.hibernate.cfg.Binder - Mapping joined-subclass: DossierWeb -> DOSSIER_WEB
05 mars 13:58:30 DEBUG [main] net.sf.hibernate.cfg.Binder - Mapped property: pk -> PK, type: integer
05 mars 13:58:30 DEBUG [main] net.sf.hibernate.cfg.Binder - Mapped property: mot -> MOT, type: string
05 mars 13:58:30 INFO [main] net.sf.hibernate.cfg.Configuration - Configured SessionFactory: null
05 mars 13:58:30 DEBUG [main] net.sf.hibernate.cfg.Configuration - properties: ---------ZAPPED-----
05 mars 13:58:30 INFO [main] net.sf.hibernate.cfg.Configuration - processing one-to-many association mappings
05 mars 13:58:30 INFO [main] net.sf.hibernate.cfg.Configuration - processing one-to-one association property references
05 mars 13:58:30 INFO [main] net.sf.hibernate.cfg.Configuration - processing foreign key constraints
05 mars 13:58:30 DEBUG [main] net.sf.hibernate.cfg.Configuration - resolving reference to class: Dossier
05 mars 13:58:30 INFO [main] net.sf.hibernate.dialect.Dialect - Using dialect: net.sf.hibernate.dialect.OracleDialect
05 mars 13:58:30 INFO [main] net.sf.hibernate.cfg.SettingsFactory - Use outer join fetching: true
05 mars 13:58:30 INFO [main] net.sf.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
05 mars 13:58:30 INFO [main] net.sf.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
05 mars 13:58:30 INFO [main] net.sf.hibernate.connection.DriverManagerConnectionProvider - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@serveur:1521:marco
05 mars 13:58:30 INFO [main] net.sf.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=david, password=marcomp}
05 mars 13:58:30 INFO [main] net.sf.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
05 mars 13:58:30 DEBUG [main] net.sf.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
05 mars 13:58:30 DEBUG [main] net.sf.hibernate.connection.DriverManagerConnectionProvider - opening new JDBC connection
05 mars 13:58:30 DEBUG [main] net.sf.hibernate.connection.DriverManagerConnectionProvider - created connection to: jdbc:oracle:thin:@serveur:1521:marco, Isolation Level: 2
05 mars 13:58:30 DEBUG [main] net.sf.hibernate.connection.DriverManagerConnectionProvider - returning connection to pool, pool size: 1
05 mars 13:58:30 INFO [main] net.sf.hibernate.cfg.SettingsFactory - Use scrollable result sets: true
05 mars 13:58:30 INFO [main] net.sf.hibernate.cfg.SettingsFactory - Use JDBC3 getGeneratedKeys(): false
05 mars 13:58:30 INFO [main] net.sf.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: false
05 mars 13:58:30 INFO [main] net.sf.hibernate.cfg.SettingsFactory - echoing all SQL to stdout
05 mars 13:58:30 INFO [main] net.sf.hibernate.cfg.SettingsFactory - Query language substitutions: {}
05 mars 13:58:30 INFO [main] net.sf.hibernate.cfg.SettingsFactory - cache provider: net.sf.ehcache.hibernate.Provider
05 mars 13:58:30 INFO [main] net.sf.hibernate.cfg.Configuration - instantiating and configuring caches
05 mars 13:58:31 INFO [main] net.sf.hibernate.impl.SessionFactoryImpl - building session factory
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.impl.SessionFactoryImpl - instantiating session factory with properties:---------ZAPPED-----
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.impl.SessionFactoryObjectFactory - initializing class SessionFactoryObjectFactory
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.impl.SessionFactoryObjectFactory - registered: 4028886afb1b1a7800fb1b1a7abe0000 (unnamed)
05 mars 13:58:31 INFO [main] net.sf.hibernate.impl.SessionFactoryObjectFactory - no JNDI name configured
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.impl.SessionFactoryImpl - instantiated session factory
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.impl.SessionImpl - opened session
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.impl.SessionImpl - find: from Dossier
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.engine.QueryParameters - named parameters: {}
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.hql.QueryTranslator - compiling query
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.impl.SessionImpl - flushing session
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.impl.SessionImpl - Flushing entities and processing referenced collections
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.impl.SessionImpl - Processing unreferenced collections
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.impl.SessionImpl - Scheduling collection removes/(re)creates/updates
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.impl.SessionImpl - Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.impl.SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.impl.SessionImpl - Dont need to execute flush
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.hql.QueryTranslator - HQL: from Dossier
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.hql.QueryTranslator - SQL: select dossier0_.ID as ID, decode (dossier0_.ID, dossier0__1_.PARENT_ID, 1,0 ) as clazz_, dossier0_.LABEL as LABEL0_, dossier0__1_.PK as PK1_, dossier0__1_.MOT as MOT1_ from DOSSIER dossier0_, DOSSIER_WEB dossier0__1_ where dossier0_.ID=dossier0__1_.PARENT_ID(+)
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.connection.DriverManagerConnectionProvider - using pooled JDBC connection, pool size: 0
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.SQL - select dossier0_.ID as ID, decode (dossier0_.ID, dossier0__1_.PARENT_ID, 1,0 ) as clazz_, dossier0_.LABEL as LABEL0_, dossier0__1_.PK as PK1_, dossier0__1_.MOT as MOT1_ from DOSSIER dossier0_, DOSSIER_WEB dossier0__1_ where dossier0_.ID=dossier0__1_.PARENT_ID(+)
Hibernate: select dossier0_.ID as ID, decode (dossier0_.ID, dossier0__1_.PARENT_ID, 1,0 ) as clazz_, dossier0_.LABEL as LABEL0_, dossier0__1_.PK as PK1_, dossier0__1_.MOT as MOT1_ from DOSSIER dossier0_, DOSSIER_WEB dossier0__1_ where dossier0_.ID=dossier0__1_.PARENT_ID(+)
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.loader.Loader - processing result set
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.type.IntegerType - returning '1' as column: ID
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.loader.Loader - result row: 1
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.type.IntegerType - returning '1' as column: clazz_
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.loader.Loader - Initializing object from ResultSet: 1
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.loader.Loader - Hydrating entity: DossierWeb#1
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.type.IntegerType - returning '1' as column: PK1_
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.type.StringType - returning 'label2' as column: MOT1_
05 mars 13:58:31 DEBUG [main] net.sf.hibernate.util.JDBCExceptionReporter - SQL Exception
java.sql.SQLException: Le flux de donn


Top
 Profile  
 
 Post subject: Oracle LONG with association mapping Problem
PostPosted: Thu Mar 11, 2004 7:27 am 
Newbie

Joined: Thu Mar 11, 2004 6:44 am
Posts: 3
Location: Milano Italy
Hibernate 2.1.2
Oracle 8.1.7

Below are the artifacts of the problem (log, exception, etc...).

I have the same (similar) Oracle LONG problem as yopiyop. I am trying to map a java.lang.String property to a LONG column. Bascially during the loading/hydrating process the final call - rs.getXXX() - crashes because the stream is closed. After looking at the docs, source and some Oracle documentation (googled jdbc Oracle LONG), I attempted to use the binary and text types to no avail. The BinaryType.get() method seems like it should work (similar implementation to what the Oracle docs recommend) but perhaps some other hidden operation on the stream gets called which closes it? I have no idea, reading the source it seems that it should work.

I suspect that the problem is related to whatever happens with the loading of association mappings. I have a many-to-one association in the mapping and, strangely, when I comment this mapping out, the LONG column gets loaded with no problem. Just to be clear, the LONG column has nothing to do with the many-to-one association. Likewise, if I comment out the many-to-one mapping and set the LONG mapping type to string, the loading works just fine.

Hence, I must conclude that the problem is caused by using these two things together: Oracle LONG columns and association mappings. It's hard to see from the code what gets called when in the presence of an association mapping. I have considered writing a user type but I don't think that will help as StringType or BinaryType should work.

Any help is appreciated. And yes, Hibernate ROCKS! Thanks!

Brian

Mapping doc:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="it.ingfunds.devtrack.model">

<class name="Attivita" table="attivita">
<id name="id">
<generator class="assigned"/>
</id>
<property name="action" />
<property name="allocare" />
<property name="applicazione" />
<property name="causale" />
<property name="centroCosto" column="centro_costo" />
<property name="costo" />
<property name="costoGiorni" column="costo_giorni" />
<property name="dataApertura" column="data_apertura" not-null="true" />
<property name="dataChiusura" column="data_chiusura" />
<property name="dataScadenza" column="data_scadenza" />
<property name="dataTest" column="data_test" />
<property name="descrizione" not-null="true" />
<property name="interventi" />
<property name="msp" />
<property name="numeroProgetto" column="numero_progetto" />
<property name="percentuale" />
<property name="priorita" not-null="true" />
<property name="prodotto" />
<property name="profiloUtente" column="profilo_utente" />
<many-to-one name="richiedente" cascade="none" />
<property name="squadra" not-null="true" />
<property name="stato" not-null="true" />
<property name="supportoIt" column="supporto_it" />
<property name="tipo" />
<property name="utenteTest" column="utente_test" />
</class>

</hibernate-mapping>

Partial Log with Stack Trace:
12:16:20,069 DEBUG SessionImpl:531 - opened session
12:16:20,069 DEBUG JDBCTransaction:37 - begin
12:16:20,069 DEBUG DriverManagerConnectionProvider:78 - total checked-out connections: 0
12:16:20,069 DEBUG DriverManagerConnectionProvider:84 - using pooled JDBC connection, pool size: 0
12:16:20,069 DEBUG JDBCTransaction:41 - current autocommit status:false
12:16:20,069 DEBUG SessionImpl:1950 - loading [it.ingfunds.devtrack.model.Attivita#1261]
12:16:20,069 DEBUG SessionImpl:2047 - attempting to resolve [it.ingfunds.devtrack.model.Attivita#1261]
12:16:20,079 DEBUG SessionImpl:3346 - running Session.finalize()
12:16:20,079 DEBUG SessionImpl:2080 - object not resolved in any cache [it.ingfunds.devtrack.model.Attivita#1261]
12:16:20,079 DEBUG EntityPersister:416 - Materializing entity: [it.ingfunds.devtrack.model.Attivita#1261]
12:16:20,089 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
12:16:20,089 DEBUG SQL:237 - select attivita0_.id as id1_, attivita0_.action as action1_, attivita0_.allocare as allocare1_, attivita0_.applicazione as applicaz4_1_, attivita0_.causale as causale1_, attivita0_.centro_costo as centro_c6_1_, attivita0_.costo as costo1_, attivita0_.costo_giorni as costo_gi8_1_, attivita0_.data_apertura as data_ape9_1_, attivita0_.data_chiusura as data_ch10_1_, attivita0_.data_scadenza as data_sc11_1_, attivita0_.data_test as data_test1_, attivita0_.descrizione as descriz13_1_, attivita0_.interventi as interventi1_, attivita0_.msp as msp1_, attivita0_.numero_progetto as numero_16_1_, attivita0_.percentuale as percent17_1_, attivita0_.priorita as priorita1_, attivita0_.prodotto as prodotto1_, attivita0_.profilo_utente as profilo20_1_, attivita0_.richiedente as richied21_1_, attivita0_.squadra as squadra1_, attivita0_.stato as stato1_, attivita0_.supporto_it as support24_1_, attivita0_.tipo as tipo1_, attivita0_.utente_test as utente_26_1_, richiedent1_.id as id0_, richiedent1_.attivo as attivo0_, richiedent1_.nominativo as nominativo0_, richiedent1_.num_telefono as num_tele4_0_, richiedent1_.ufficio as ufficio0_ from attivita attivita0_, richiedente richiedent1_ where attivita0_.id=? and attivita0_.richiedente=richiedent1_.id(+)
Hibernate: select attivita0_.id as id1_, attivita0_.action as action1_, attivita0_.allocare as allocare1_, attivita0_.applicazione as applicaz4_1_, attivita0_.causale as causale1_, attivita0_.centro_costo as centro_c6_1_, attivita0_.costo as costo1_, attivita0_.costo_giorni as costo_gi8_1_, attivita0_.data_apertura as data_ape9_1_, attivita0_.data_chiusura as data_ch10_1_, attivita0_.data_scadenza as data_sc11_1_, attivita0_.data_test as data_test1_, attivita0_.descrizione as descriz13_1_, attivita0_.interventi as interventi1_, attivita0_.msp as msp1_, attivita0_.numero_progetto as numero_16_1_, attivita0_.percentuale as percent17_1_, attivita0_.priorita as priorita1_, attivita0_.prodotto as prodotto1_, attivita0_.profilo_utente as profilo20_1_, attivita0_.richiedente as richied21_1_, attivita0_.squadra as squadra1_, attivita0_.stato as stato1_, attivita0_.supporto_it as support24_1_, attivita0_.tipo as tipo1_, attivita0_.utente_test as utente_26_1_, richiedent1_.id as id0_, richiedent1_.attivo as attivo0_, richiedent1_.nominativo as nominativo0_, richiedent1_.num_telefono as num_tele4_0_, richiedent1_.ufficio as ufficio0_ from attivita attivita0_, richiedente richiedent1_ where attivita0_.id=? and attivita0_.richiedente=richiedent1_.id(+)
12:16:20,089 DEBUG BatcherImpl:241 - preparing statement
12:16:20,129 DEBUG Loader:197 - processing result set
12:16:20,149 DEBUG Loader:405 - result row: 15, 1261
12:16:20,159 DEBUG Loader:536 - Initializing object from ResultSet: 15
12:16:20,159 DEBUG Loader:605 - Hydrating entity: it.ingfunds.devtrack.model.Richiedente#15
12:16:20,159 DEBUG Loader:536 - Initializing object from ResultSet: 1261
12:16:20,169 DEBUG Loader:605 - Hydrating entity: it.ingfunds.devtrack.model.Attivita#1261
12:16:20,219 DEBUG JDBCExceptionReporter:36 - SQL Exception
java.sql.SQLException: Il flusso


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.