-->
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.  [ 3 posts ] 
Author Message
 Post subject: collectionSnapshot is NULL
PostPosted: Tue May 10, 2005 12:30 pm 
Newbie

Joined: Thu May 05, 2005 5:49 pm
Posts: 11
Location: San Diego, California
I am attempting to instantiate and fill my own PersistentCollection. However, when I do so, I get an NPE on the collectionSnapshot contained within the Persistent Collection.

I am writing a method which takes a custom PersistentCollection and finds records meeting certain criteria. In this example, the criteria is records that have a certain date. The client provided the PersistentCollection and the date to my method. I then loop through the collection finding records meeting the criteria and return a new PersistentCollection that contains only the records meeting the criteria.

However, when I try to call getSize() on the PersistentCollection that is returned from my method, I get the NPE. Do I need to initialize the collectionSnapshot somehow? I looked through the source code and didn't see an API to do that. It seems like the collectionSnapshot is maintained internally.

Thanks in advance.

A

Hibernate version:
3.0.2

Mapping documents:
N/A

Code between sessionFactory.openSession() and session.close():
Code:
    public StudentVaccinationCollection getVaccinationsByDate(Object collection, Date date)
    {
        //These next 2 lines are how I create the PersistentCollection
        StudentVaccinationCollection coll = new StudentVaccinationCollection(getSession());
        coll = (StudentVaccinationCollection)coll.wrap(getSession(), (Map)collection);

        Set set = ((StudentVaccinationCollection) collection).entrySet();
        for (Iterator iterator = set.iterator(); iterator.hasNext();)
        {
            Map.Entry entry = (Map.Entry) iterator.next();
            StudentVaccination sv = (StudentVaccination) entry.getValue();
            if (sdf.format(sv.getVaccinationDate()).equals(sdf.format(date)))
            {
                Long id = new Long(sv.getStudentVaccId());
                coll.put(id, sv);
            }
        }
        return coll;
    }



Full stack trace of any exception that occurs:
Code:
java.lang.NullPointerException
   at org.hibernate.collection.AbstractPersistentCollection.write(AbstractPersistentCollection.java:62)
   at org.hibernate.collection.PersistentMap.put(PersistentMap.java:130)
   at com.maximus.schoolmax.health.StudentVaccinationCollection.getVaccinationsByDate(StudentVaccinationCollection.java:129)
   at com.maximus.schoolmax.student.TestStudentModel.validateStudent(TestStudentModel.java:343)
   at com.maximus.schoolmax.student.TestStudentModel.readStudentByExtStudentNumber(TestStudentModel.java:230)
   at com.maximus.schoolmax.student.TestStudentModel.testStudent(TestStudentModel.java:101)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)


Name and version of the database you are using:
Code:
N/A


The generated SQL (show_sql=true):
Code:
N/A


Debug level Hibernate log excerpt:
Code:
09:26:44,445  INFO Environment:464 - Hibernate 3.0.2
09:26:44,455  INFO Environment:477 - hibernate.properties not found
09:26:44,455  INFO Environment:510 - using CGLIB reflection optimizer
09:26:44,455  INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
09:26:44,545  INFO Configuration:1160 - configuring from resource: /hibernate.cfg.xml
09:26:44,645  INFO Configuration:1131 - Configuration resource: /hibernate.cfg.xml
09:26:45,746  INFO Configuration:441 - Mapping resource: com/maximus/schoolmax/health/model/Vaccination.hbm.xml
09:26:45,917  INFO HbmBinder:258 - Mapping class: com.maximus.schoolmax.health.model.Vaccination -> ENUM_HE_VACCINATIONS
09:26:45,947  INFO Configuration:441 - Mapping resource: com/maximus/schoolmax/health/model/VaccinationExtensions.hbm.xml
09:26:45,997  INFO HbmBinder:258 - Mapping class: com.maximus.schoolmax.health.model.VaccinationExtensions -> HE_VACC_EXTENSIONS
09:26:45,997  INFO Configuration:441 - Mapping resource: com/maximus/schoolmax/health/model/VaccinationAttributes.hbm.xml
09:26:46,037  INFO HbmBinder:258 - Mapping class: com.maximus.schoolmax.health.model.VaccinationAttributes -> HE_VACC_ATTRIBUTES
09:26:46,117  INFO Configuration:441 - Mapping resource: com/maximus/schoolmax/health/model/Exemption.hbm.xml
09:26:46,157  INFO HbmBinder:258 - Mapping class: com.maximus.schoolmax.health.model.Exemption -> ENUM_HE_EXEMPTIONS
09:26:46,167  INFO Configuration:441 - Mapping resource: com/maximus/schoolmax/health/model/StudentVaccination.hbm.xml
09:26:46,187  INFO HbmBinder:258 - Mapping class: com.maximus.schoolmax.health.model.StudentVaccination -> ST_STUDENT_VACCINATION
09:26:46,197  INFO Configuration:441 - Mapping resource: com/maximus/schoolmax/health/model/StudentVaccExemption.hbm.xml
09:26:46,227  INFO HbmBinder:258 - Mapping class: com.maximus.schoolmax.health.model.StudentVaccExemption -> ST_STUDENT_VACC_EXEMPTION
09:26:46,227  INFO Configuration:441 - Mapping resource: com/maximus/schoolmax/student/model/Student.hbm.xml
09:26:46,257  INFO HbmBinder:258 - Mapping class: com.maximus.schoolmax.student.model.Student -> CE_FAMILY_MEMBER
09:26:46,257  INFO Configuration:1272 - Configured SessionFactory: null
09:26:46,257  INFO Configuration:852 - processing extends queue
09:26:46,257  INFO Configuration:856 - processing collection mappings
09:26:46,257  INFO HbmBinder:1974 - Mapping collection: com.maximus.schoolmax.health.model.Vaccination.customAttributes -> HE_VACC_ATTRIBUTES
09:26:46,257  INFO HbmBinder:1974 - Mapping collection: com.maximus.schoolmax.student.model.Student.vaccinations -> ST_STUDENT_VACCINATION
09:26:46,267  INFO HbmBinder:1974 - Mapping collection: com.maximus.schoolmax.student.model.Student.exemptions -> ST_STUDENT_VACC_EXEMPTION
09:26:46,267  INFO Configuration:865 - processing association property references
09:26:46,267  INFO Configuration:894 - processing foreign key constraints
09:26:46,277  INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
09:26:46,277  INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
09:26:46,277  INFO DriverManagerConnectionProvider:45 - autocommit mode: false
09:26:46,287  INFO DriverManagerConnectionProvider:80 - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@10.200.110.50:1521:sazdb1
09:26:46,287  INFO DriverManagerConnectionProvider:86 - connection properties: {user=smax_cycle9, password=****}
09:26:46,728  INFO SettingsFactory:71 - RDBMS: Oracle, version: Oracle Database 10g Release 10.1.0.3.0 - Production
09:26:46,738  INFO SettingsFactory:72 - JDBC driver: Oracle JDBC driver, version: 10.1.0.2.0
09:26:46,748  INFO Dialect:92 - Using dialect: org.hibernate.dialect.Oracle9Dialect
09:26:46,758  INFO SettingsFactory:122 - JDBC batch size: 15
09:26:46,758  INFO SettingsFactory:125 - JDBC batch updates for versioned data: disabled
09:26:46,768  INFO SettingsFactory:130 - Scrollable result sets: enabled
09:26:46,768  INFO SettingsFactory:138 - JDBC3 getGeneratedKeys(): disabled
09:26:46,768  INFO SettingsFactory:150 - Aggressive release : disabled
09:26:46,768  INFO SettingsFactory:166 - Default batch fetch size: 1
09:26:46,768  INFO SettingsFactory:170 - Generate SQL with comments: disabled
09:26:46,768  INFO SettingsFactory:174 - Order SQL updates by primary key: disabled
09:26:46,778  INFO SettingsFactory:312 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
09:26:46,778  INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
09:26:46,778  INFO SettingsFactory:182 - Query language substitutions: {}
09:26:46,788  INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
09:26:46,788  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
09:26:46,788  INFO SettingsFactory:191 - Automatic flush during beforeCompletion(): disabled
09:26:46,788  INFO SettingsFactory:195 - Automatic session close at end of transaction: disabled
09:26:46,788  INFO SettingsFactory:201 - Second-level cache: enabled
09:26:46,788  INFO SettingsFactory:205 - Query cache: disabled
09:26:46,788  INFO SettingsFactory:299 - Cache provider: org.hibernate.cache.EhCacheProvider
09:26:46,798  INFO SettingsFactory:220 - Optimize cache for minimal puts: disabled
09:26:46,798  INFO SettingsFactory:229 - Structured second-level cache entries: enabled
09:26:46,808  INFO SettingsFactory:249 - Echoing all SQL to stdout
09:26:46,808  INFO SettingsFactory:253 - Statistics: disabled
09:26:46,808  INFO SettingsFactory:257 - Deleted entity synthetic identifier rollback: disabled
09:26:46,808  INFO SettingsFactory:271 - Default entity-mode: pojo
09:26:46,928  INFO SessionFactoryImpl:148 - building session factory
09:26:46,958  WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/hibernate-3.0/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
09:26:47,669  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
09:26:47,669  INFO SessionFactoryImpl:374 - Checking 0 named queries
Hibernate: select vaccinatio0_.VACCINATION_ID as VACCINAT1_, vaccinatio0_.DISTRICT_NUMBER as DISTRICT2_0_, vaccinatio0_.DESCRIPTION as DESCRIPT3_0_, vaccinatio0_.IS_ACTIVE_IND as IS4_0_, vaccinatio0_.MESSAGE_KEY as MESSAGE5_0_, vaccinatio0_.NAME as NAME0_, vaccinatio0_.ORDER_DEFAULT as ORDER7_0_, vaccinatio0_.REPORT_LABEL as REPORT8_0_, vaccinatio0_.VALUE as VALUE0_, vaccinatio0_.UPDATED_BY as UPDATED10_0_, vaccinatio0_.UPDATED_TS as UPDATED11_0_ from ENUM_HE_VACCINATIONS vaccinatio0_
Hibernate: select customattr0_.VACCINATION_ID as VACCINAT5___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1___, customattr0_.VACC_EXT_ID as VACC6___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1_0_, customattr0_.VALUE as VALUE2_0_, customattr0_.UPDATED_BY as UPDATED3_2_0_, customattr0_.UPDATED_TS as UPDATED4_2_0_, customattr0_.VACCINATION_ID as VACCINAT5_2_0_, customattr0_.VACC_EXT_ID as VACC6_2_0_ from HE_VACC_ATTRIBUTES customattr0_ where customattr0_.VACCINATION_ID=?
Hibernate: select customattr0_.VACCINATION_ID as VACCINAT5___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1___, customattr0_.VACC_EXT_ID as VACC6___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1_0_, customattr0_.VALUE as VALUE2_0_, customattr0_.UPDATED_BY as UPDATED3_2_0_, customattr0_.UPDATED_TS as UPDATED4_2_0_, customattr0_.VACCINATION_ID as VACCINAT5_2_0_, customattr0_.VACC_EXT_ID as VACC6_2_0_ from HE_VACC_ATTRIBUTES customattr0_ where customattr0_.VACCINATION_ID=?
Hibernate: select customattr0_.VACCINATION_ID as VACCINAT5___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1___, customattr0_.VACC_EXT_ID as VACC6___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1_0_, customattr0_.VALUE as VALUE2_0_, customattr0_.UPDATED_BY as UPDATED3_2_0_, customattr0_.UPDATED_TS as UPDATED4_2_0_, customattr0_.VACCINATION_ID as VACCINAT5_2_0_, customattr0_.VACC_EXT_ID as VACC6_2_0_ from HE_VACC_ATTRIBUTES customattr0_ where customattr0_.VACCINATION_ID=?
Hibernate: select customattr0_.VACCINATION_ID as VACCINAT5___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1___, customattr0_.VACC_EXT_ID as VACC6___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1_0_, customattr0_.VALUE as VALUE2_0_, customattr0_.UPDATED_BY as UPDATED3_2_0_, customattr0_.UPDATED_TS as UPDATED4_2_0_, customattr0_.VACCINATION_ID as VACCINAT5_2_0_, customattr0_.VACC_EXT_ID as VACC6_2_0_ from HE_VACC_ATTRIBUTES customattr0_ where customattr0_.VACCINATION_ID=?
Hibernate: select customattr0_.VACCINATION_ID as VACCINAT5___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1___, customattr0_.VACC_EXT_ID as VACC6___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1_0_, customattr0_.VALUE as VALUE2_0_, customattr0_.UPDATED_BY as UPDATED3_2_0_, customattr0_.UPDATED_TS as UPDATED4_2_0_, customattr0_.VACCINATION_ID as VACCINAT5_2_0_, customattr0_.VACC_EXT_ID as VACC6_2_0_ from HE_VACC_ATTRIBUTES customattr0_ where customattr0_.VACCINATION_ID=?
Hibernate: select customattr0_.VACCINATION_ID as VACCINAT5___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1___, customattr0_.VACC_EXT_ID as VACC6___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1_0_, customattr0_.VALUE as VALUE2_0_, customattr0_.UPDATED_BY as UPDATED3_2_0_, customattr0_.UPDATED_TS as UPDATED4_2_0_, customattr0_.VACCINATION_ID as VACCINAT5_2_0_, customattr0_.VACC_EXT_ID as VACC6_2_0_ from HE_VACC_ATTRIBUTES customattr0_ where customattr0_.VACCINATION_ID=?
Hibernate: select customattr0_.VACCINATION_ID as VACCINAT5___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1___, customattr0_.VACC_EXT_ID as VACC6___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1_0_, customattr0_.VALUE as VALUE2_0_, customattr0_.UPDATED_BY as UPDATED3_2_0_, customattr0_.UPDATED_TS as UPDATED4_2_0_, customattr0_.VACCINATION_ID as VACCINAT5_2_0_, customattr0_.VACC_EXT_ID as VACC6_2_0_ from HE_VACC_ATTRIBUTES customattr0_ where customattr0_.VACCINATION_ID=?
Hibernate: select customattr0_.VACCINATION_ID as VACCINAT5___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1___, customattr0_.VACC_EXT_ID as VACC6___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1_0_, customattr0_.VALUE as VALUE2_0_, customattr0_.UPDATED_BY as UPDATED3_2_0_, customattr0_.UPDATED_TS as UPDATED4_2_0_, customattr0_.VACCINATION_ID as VACCINAT5_2_0_, customattr0_.VACC_EXT_ID as VACC6_2_0_ from HE_VACC_ATTRIBUTES customattr0_ where customattr0_.VACCINATION_ID=?
Hibernate: select customattr0_.VACCINATION_ID as VACCINAT5___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1___, customattr0_.VACC_EXT_ID as VACC6___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1_0_, customattr0_.VALUE as VALUE2_0_, customattr0_.UPDATED_BY as UPDATED3_2_0_, customattr0_.UPDATED_TS as UPDATED4_2_0_, customattr0_.VACCINATION_ID as VACCINAT5_2_0_, customattr0_.VACC_EXT_ID as VACC6_2_0_ from HE_VACC_ATTRIBUTES customattr0_ where customattr0_.VACCINATION_ID=?
Hibernate: select customattr0_.VACCINATION_ID as VACCINAT5___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1___, customattr0_.VACC_EXT_ID as VACC6___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1_0_, customattr0_.VALUE as VALUE2_0_, customattr0_.UPDATED_BY as UPDATED3_2_0_, customattr0_.UPDATED_TS as UPDATED4_2_0_, customattr0_.VACCINATION_ID as VACCINAT5_2_0_, customattr0_.VACC_EXT_ID as VACC6_2_0_ from HE_VACC_ATTRIBUTES customattr0_ where customattr0_.VACCINATION_ID=?
Hibernate: select customattr0_.VACCINATION_ID as VACCINAT5___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1___, customattr0_.VACC_EXT_ID as VACC6___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1_0_, customattr0_.VALUE as VALUE2_0_, customattr0_.UPDATED_BY as UPDATED3_2_0_, customattr0_.UPDATED_TS as UPDATED4_2_0_, customattr0_.VACCINATION_ID as VACCINAT5_2_0_, customattr0_.VACC_EXT_ID as VACC6_2_0_ from HE_VACC_ATTRIBUTES customattr0_ where customattr0_.VACCINATION_ID=?
Hibernate: select customattr0_.VACCINATION_ID as VACCINAT5___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1___, customattr0_.VACC_EXT_ID as VACC6___, customattr0_.ATTRIBUTE_ID as ATTRIBUTE1_0_, customattr0_.VALUE as VALUE2_0_, customattr0_.UPDATED_BY as UPDATED3_2_0_, customattr0_.UPDATED_TS as UPDATED4_2_0_, customattr0_.VACCINATION_ID as VACCINAT5_2_0_, customattr0_.VACC_EXT_ID as VACC6_2_0_ from HE_VACC_ATTRIBUTES customattr0_ where customattr0_.VACCINATION_ID=?
Hibernate: select exemption0_.EXEMPTION_ID as EXEMPTION1_, exemption0_.DISTRICT_NUMBER as DISTRICT2_3_, exemption0_.DESCRIPTION as DESCRIPT3_3_, exemption0_.IS_ACTIVE_IND as IS4_3_, exemption0_.MESSAGE_KEY as MESSAGE5_3_, exemption0_.NAME as NAME3_, exemption0_.ORDER_DEFAULT as ORDER7_3_, exemption0_.REPORT_LABEL as REPORT8_3_, exemption0_.VALUE as VALUE3_, exemption0_.UPDATED_BY as UPDATED10_3_, exemption0_.UPDATED_TS as UPDATED11_3_ from ENUM_HE_EXEMPTIONS exemption0_
Hibernate: select CE_FAMILY_MBR_SEQ.nextval from dual
Hibernate: select STUDENT_VACC_SEQ.nextval from dual
Hibernate: select STUDENT_VACC_SEQ.nextval from dual
Hibernate: select STUDENT_EXEMPTION_SEQ.nextval from dual
Hibernate: insert into CE_FAMILY_MEMBER (FIRST_NAME, MIDDLE_NAME, LAST_NAME, GENDER, DATE_OF_BIRTH, HEALTH_COMPLIANT, EXT_STUDENT_NUMBER, UPDATED_BY, UPDATE_TS, DISTRICT_NUMBER, EMAIL, STUDENT_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into ST_STUDENT_VACCINATION (VACCINATION_DATE, AGE_AT_VACCINATION, UPDATED_BY, UPDATED_TS, VACCINATION_SEQ, STUDENT_ID, VACCINATION_ID, STUDENT_VACC_ID) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into ST_STUDENT_VACCINATION (VACCINATION_DATE, AGE_AT_VACCINATION, UPDATED_BY, UPDATED_TS, VACCINATION_SEQ, STUDENT_ID, VACCINATION_ID, STUDENT_VACC_ID) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into ST_STUDENT_VACC_EXEMPTION (AS_OF_DATE, UPDATED_BY, UPDATED_TS, STUDENT_ID, VACCINATION_ID, EXEMPTION_ID, STUDENT_EXEMPTION_ID) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: select student0_.STUDENT_ID as STUDENT1_, student0_.FIRST_NAME as FIRST2_6_, student0_.MIDDLE_NAME as MIDDLE3_6_, student0_.LAST_NAME as LAST4_6_, student0_.GENDER as GENDER6_, student0_.DATE_OF_BIRTH as DATE6_6_, student0_.HEALTH_COMPLIANT as HEALTH7_6_, student0_.EXT_STUDENT_NUMBER as EXT8_6_, student0_.UPDATED_BY as UPDATED9_6_, student0_.UPDATE_TS as UPDATE10_6_, student0_.DISTRICT_NUMBER as DISTRICT11_6_, student0_.EMAIL as EMAIL6_ from CE_FAMILY_MEMBER student0_ where DISTRICT_NUMBER=? and EXT_STUDENT_NUMBER=?
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 1:54 pm 
Newbie

Joined: Thu May 05, 2005 5:49 pm
Posts: 11
Location: San Diego, California
Does anyone have any ideas on this? I'm really stuck on this. I've been trying to figure this out for 2 days. Any suggestions would be appreciated.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 12, 2005 11:03 am 
Newbie

Joined: Thu May 05, 2005 5:49 pm
Posts: 11
Location: San Diego, California
can anyone help on this?


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