I've inherited a puzzle that I can't quite put together. I've created a new class that maps to a simple Oracle table. I want to use session.save() to build up a small cache of records and then commit them at once.
I cannot get the mapping straightened out. The project uses a persistence.xml file for it's base persistence mapping file. I have created an individual mapping file for this single class and others that might be related. The code and configuration follow:
// Java class declaration
package gov.va.med.hac.edi.extract.feeclaimstatus.feeFinal;
@Entity public class Stage277 {
@Id private String claimIndex; ....... more fields public Stage277() {} // getters, setters etc......... }
// configuration files declarations // individual file that references only this class File: stg277Mapping.xml <?xml version="1.0" encoding="UTF-8"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd" version="1.0"> <persistence-unit-metadata> <xml-mapping-metadata-complete /> </persistence-unit-metadata> <entity class="gov.va.med.hac.edi.extract.feeclaimstatus.feeFinal.Stage277" metadata-complete="false"> <id name="claimIndex" column="CLAIM_INDEX" type="integer"/> <table name="STG_277" /> <inheritance /> <attributes> <transient name="claimIndex"/> <transient name="claimStatusCode"/> <transient name="dateCreated" /> <transient name="modifiedBy" /> <transient name="createdBy" /> <transient name="dateModified" /> </attributes> </entity> </entity-mappings>
// base configuration file - I believe (this isn't my project and the point-man is on vacation....) File: persistence.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- Persistence deployment descriptor for dev profile --> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
// DECLARATION FOR ABOVE MAPPING FILE. <persistence-unit name="stg277"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <mapping-file>META-INF/stg277Mapping.xml</mapping-file> <class>gov.va.med.hac.edi.extract.feeclaimstatus.feeFinal.Stage277</class> </persistence-unit> ....many, many more entries follow..... </persistence>
java code to be run to save() and commit transaction
EntityManager em;
Session session = (Session) em.getDelegate();
// EntityTransaction tx = em.getTransaction();
Stage277 stg277 = new Stage277("claimIndex", "claimStatusCode", "BILL", sqlDate);
// crashes here........... session.save(stg277);
........... WHY ISN'T THE CLASS BEING FOUND BY THE ENTITY MANAGER ? .................
Error Message: org.hibernate.MappingException: Unknown entity: gov.va.med.hac.edi.extract.feeclaimstatus.feeFinal.Stage277 -----------------------------------------------------------------------------------------------------------
Any help is GREATLY appreciated!
|