-->
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.  [ 4 posts ] 
Author Message
 Post subject: Array across columns?
PostPosted: Tue Mar 01, 2005 12:54 pm 
Newbie

Joined: Tue Mar 01, 2005 12:33 pm
Posts: 3
Hi guys,

I have read all the FAQs etc, but can't seem to find what I am looking for. I also bought Hibernate in Action and can't find it in there either. I have searched as well. Everything that covers arrays, is more along the lines of pulling out multiple rows of data into an array (or an array of objects).

Maybe this isn't possible and I am just going to have to code the bean the normal way, but is there a way to do the following:

I have hourly data that I am pulling out of an XML report.

What I would like to do is create a member called Hourly[] and have that map to each individual column Hour1 - Hour24.

Does this make sense? It seems rather redundant to code each column to a seperate member in the bean if they are holding the same type of data.

Thanks,

B

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 12:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You can have a map with ("hour1" -> xxx, ... "hour24" -> xxx) using dynamic-component ...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 04, 2005 1:18 pm 
Newbie

Joined: Tue Mar 01, 2005 12:33 pm
Posts: 3
Thanks for the reply, but I am having troubles implementing this.

Here is my mapping. Is this set up properly? There doesn't seem to be very much documentation on dynamic-components. Maybe I am just missing something?

Code:
    <dynamic-component name="hour">
          <property name="H1" column="H1" type="java.math.BigDecimal"/>
          <property name="H2" column="H2" type="java.math.BigDecimal"/>
          <property name="H3" column="H3" type="java.math.BigDecimal"/>
          <property name="H4" column="H4" type="java.math.BigDecimal"/>
          <property name="H5" column="H5" type="java.math.BigDecimal"/>
          <property name="H6" column="H6" type="java.math.BigDecimal"/>
          <property name="H7" column="H7" type="java.math.BigDecimal"/>
          <property name="H8" column="H8" type="java.math.BigDecimal"/>
          <property name="H9" column="H9" type="java.math.BigDecimal"/>
          <property name="H10" column="H10" type="java.math.BigDecimal"/>
          <property name="H11" column="H11" type="java.math.BigDecimal"/>
          <property name="H12" column="H12" type="java.math.BigDecimal"/>
          <property name="H13" column="H13" type="java.math.BigDecimal"/>
          <property name="H14" column="H14" type="java.math.BigDecimal"/>
          <property name="H15" column="H15" type="java.math.BigDecimal"/>
          <property name="H16" column="H16" type="java.math.BigDecimal"/>
          <property name="H17" column="H17" type="java.math.BigDecimal"/>
          <property name="H18" column="H19" type="java.math.BigDecimal"/>
          <property name="H20" column="H20" type="java.math.BigDecimal"/>
          <property name="H21" column="H21" type="java.math.BigDecimal"/>
          <property name="H22" column="H22" type="java.math.BigDecimal"/>
          <property name="H23" column="H23" type="java.math.BigDecimal"/>
          <property name="H24" column="H24" type="java.math.BigDecimal"/>
      </dynamic-component>


Here is the blow up:

Code:
WARN [main] (JDBCExceptionReporter.java:57) - SQL Error: 904, SQLState: 42000
ERROR [main] (JDBCExceptionReporter.java:58) - ORA-00904: "H24": invalid identifier

WARN [main] (JDBCExceptionReporter.java:57) - SQL Error: 904, SQLState: 42000
ERROR [main] (JDBCExceptionReporter.java:58) - ORA-00904: "H24": invalid identifier

WARN [main] (JDBCExceptionReporter.java:57) - SQL Error: 904, SQLState: 42000
ERROR [main] (JDBCExceptionReporter.java:58) - ORA-00904: "H24": invalid identifier

WARN [main] (JDBCExceptionReporter.java:57) - SQL Error: 904, SQLState: 42000
ERROR [main] (JDBCExceptionReporter.java:58) - ORA-00904: "H24": invalid identifier

ERROR [main] (SessionImpl.java:2400) - Could not synchronize database state with session
ERROR [main] (BaseDAO.java:74) - Caught exception attempting BaseDAO.save:
net.sf.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
   at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:69)
   at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
   at net.sf.hibernate.impl.BatcherImpl.convert(BatcherImpl.java:328)
   at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:135)
   at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2438)
   at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2392)
   at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2261)
   at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
   at com.transalta.miso.model.dao.BaseDAO.save(BaseDAO.java:63)
   at com.transalta.miso.model.dao.StlmtTypeDAO.save(StlmtTypeDAO.java:18)
   at com.transalta.miso.model.dao.StlmtTypeDAOtest.testStlmtType(StlmtTypeDAOtest.java:54)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: java.sql.BatchUpdateException: ORA-00904: "H24": invalid identifier

   at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)
   at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:4210)
   at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:54)
   at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:128)
   ... 22 more


Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 04, 2005 4:46 pm 
Newbie

Joined: Tue Mar 01, 2005 12:33 pm
Posts: 3
nvrmnd... I am dumb.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.