-->
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.  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: one to one XML mapping
PostPosted: Tue Apr 19, 2011 3:47 am 
Beginner
Beginner

Joined: Mon Apr 18, 2011 10:01 am
Posts: 20
Hello,
I have a problem in mapping a one-to-one relationship between two objects.

The first question is, ( I use Oracle 10g and Java 1.4 ) should I set my constraint in Oracle first, before configuring the relational
mapping in the hibernate .hbm.xml file ?

Then, these are my beans, and hbm.xml files . Can anybody notice what am I doing wrong ? I am trying to set a one-to-one relationship mapping between a PcTask and his assignee , bean PcTaskAssignee. Here is the code for PcTaskAssignee

Code:
public class PcTaskAssignee extends EntityObject implements Serializable {
   
    private String  assignee = null;
    private String  phone    = null;
    private String  email    = null;
    private String  guid     = null;
    private String  isGroup  = null;
    private String  taskId   = null;
    private Double  version  = new Double(0.0);
    private IWorklistContext context;

    public PcTaskAssignee() {
    }
   
    public String getName(){
        return assignee;
    }
   
    public void setCurrentContext (IWorklistContext context) {
        // memorizzo il contesto corrente
        this.context = context;
    }
   
    public IWorklistContext getCurrentContext () {
        return (context);
    }


    public void setAssignee(String assignee) {
        this.assignee = assignee;
    }


    public String getAssignee() {
        return assignee;
    }


    public void setGuid(String guid) {
        this.guid = guid;
    }


    public String getGuid() {
        return guid;
    }


    public void setIsGroup(String isGroup) {
        this.isGroup = isGroup;
    }


    public String getIsGroup() {
        return isGroup;
    }
   
    public boolean getIsGroup(String mode) {
        if (isGroup.equalsIgnoreCase("F")){
            return false;
        } else {
            return true;
        }
    }


    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }


    public String getTaskId() {
        return taskId;
    }


    public void setVersion(Double version) {
        this.version = version;
    }


    public Double getVersion() {
        return version;
    }
   
        public void setPhone(String phone) {
        this.phone = phone;
    }


    public String getPhone() {
        return phone;
    }


    public void setEmail(String email) {
        this.email = email;
    }


    public String getEmail() {
        return email;
    }
}


and its xml mapping

Code:
<hibernate-mapping package="previtc.model.task">
    <class name="PcTaskAssignee" table="PC_TASKASSIGNEE" dynamic-update="true" dynamic-insert="true">
        <composite-id>
            <key-property name="taskId"  column="TASKID"  type="string"/>
            <key-property name="version" column="VERSION" type="double" />
            <key-property name="assignee" column="ASSIGNEE" type="string" />
        </composite-id>
        <many-to-one name=”task” class="previtc.model.task.PcTask"
            column=”TASKID”
            cascade=”all”  unique=”true”
            />
        <property name="phone"        column="PHONE"       type="string" />
        <property name="email"        column="EMAIL"       type="string" />
        <property name="guid"         column="GUID"       type="string" />
        <property name="isGroup"      column="ISGROUP"    type="string" />
    </class>
</hibernate-mapping>


And here is my PcTask class
Code:
public class PcTask extends EntityObject {

    private String  acquiredBy           = null;
    private String  approvers           = null;
    private String  comment1           = null;
    private String  comment2           = null;
    private String  comment3           = null;
    private String  comment4           = null;
    private String  comment5           = null;
    private String  conclusion           = null;
    private Date    createdDate        = null;
    private String  creator           = null;
    private String  domainId           = null;
    private Date    expirationDate        = null;
    private String  expirationDuration           = null;
    private Date    flexDate1        = null;
    private Date    flexDate2        = null;
    private Date    flexDate3        = null;
    private Double  flexDouble1       = new Double(0.0);
    private Double  flexDouble2       = new Double(0.0);
    private Double  flexLong1       = new Double(0.0);
    private Double  flexLong2       = new Double(0.0);
    private String  flexString1           = null;
    private String  flexString2           = null;
    private String  flexString3           = null;
    private String  flexString4           = null;
    private String  identificationKey           = null;
    private String  instanceId           = null;
    private String  isGroup           = null;
    private String  isHassubTask           = null;
    private Date    modifyDate        = null;
    private Integer notm    = null;
    private String  owner           = null;
    private String  pattern           = null;
    private Integer priority    = null;
    private String  processId           = null;
    private String  processName           = null;
    private String  processOwner           = null;
    private String  processVersion           = null;
    private String  state           = null;
    private String  substate           = null;
    private String  systemString1           = null;
    private String  systemString2           = null;
    private String  systemString3           = null;
    private String  taskGroupId           = null;
    private String  taskId           = null;
    private Double taskNumber    = null;
    private String  taskType           = null;
    private String  title           = null;
    private String  updatedBy           = null;
    private Integer version    = null;
    private String versionReason    = null;
    // private IWorklistContext context;
    private Element payload;
   
    public PcTask() {}


( I omitted getters and setters, but I defined them all )
followed by its mapping
Code:
<hibernate-mapping package="previtc.model.task">
    <class name="PcTask" table="PC_TASK" dynamic-update="true" dynamic-insert="true">
        <id name="taskId" column="TASKID" type="string">
            <generator class="sequence">
                <param name="sequence">PC_TASK_ID_SEQ</param>
            </generator>
        </id>
        <property name="taskNumber"         column="TASKNUMBER"                 type="double" /> 
        <property name="acquiredBy"         column="ACQUIREDBY"                 type="string" />
        <property name="approvers"          column="APPROVERS"                  type="string" />
        <property name="comment1"           column="COMMENT1"                   type="string" />
        <property name="comment2"           column="COMMENT2"                   type="string" />
        <property name="comment3"           column="COMMENT3"                   type="string" />
        <property name="comment4"           column="COMMENT4"                   type="string" />
        <property name="comment5"           column="COMMENT5"                   type="string" />
        <property name="conclusion"         column="CONCLUSION"                 type="string" />
        <property name="createdDate"        column="CREATEDDATE"                type="date" />
        <property name="creator"            column="CREATOR"                    type="string" />
        <property name="domainId"           column="DOMAINID"                   type="string" />
        <property name="expirationDate"     column="EXPIRATIONDATE"             type="date" />
        <property name="expirationDuration" column="EXPIRATIONDURATION"         type="string" />
        <property name="flexDate1"          column="FLEXDATE1"                  type="date" />
        <property name="flexDate2"          column="FLEXDATE2"                  type="date" />
        <property name="flexDate3"          column="FLEXDATE3"                  type="date" />
        <property name="flexDouble1"        column="FLEXDOUBLE1"                type="double" />
        <property name="flexDouble2"        column="FLEXDOUBLE2"                type="double" />
        <property name="flexLong1"          column="FLEXLONG1"                  type="double" />
        <property name="flexLong2"          column="FLEXLONG2"                  type="double" />
        <property name="flexString1"        column="FLEXSTRING1"                type="string" />
        <property name="flexString2"        column="FLEXSTRING2"                type="string" />
        <property name="flexString3"        column="FLEXSTRING3"                type="string" />
        <property name="flexString4"        column="FLEXSTRING4"                type="string" />
        <property name="identificationKey"  column="IDENTIFICATIONKEY"          type="string" />
        <property name="instanceId"         column="INSTANCEID"                 type="string" />
        <property name="isGroup"            column="ISGROUP"                    type="string" />
        <property name="isHassubTask"       column="ISHASSUBTASK"               type="string" />
        <property name="modifyDate"         column="MODIFYDATE"                 type="date"   />
        <property name="notm"               column="NOTM"                       type="integer"/>
        <property name="owner"              column="OWNER"                      type="string" />
        <property name="pattern"            column="PATTERN"                    type="string" />
        <property name="priority"           column="PRIORITY"                   type="integer"/>
        <property name="processId"          column="PROCESSID"                  type="string" />
        <property name="processName"        column="PROCESSNAME"                type="string" />
        <property name="processOwner"       column="PROCESSOWNER"               type="string" />
        <property name="processVersion"     column="PROCESSVERSION"             type="string" />
        <property name="state"              column="STATE"                      type="string" />
        <property name="substate"           column="SUBSTATE"                   type="string" />
        <property name="systemString1"      column="SYSTEMSTRING1"              type="string" />
        <property name="systemString2"      column="SYSTEMSTRING2"              type="string" />
        <property name="systemString3"      column="SYSTEMSTRING3"              type="string" />
        <property name="taskGroupId"        column="TASKGROUPID"                type="string" />
        <property name="taskType"           column="TASKTYPE"                   type="string" />
        <property name="title"              column="TITLE"                      type="string" />
        <property name="updatedBy"          column="UPDATEDBY"                  type="string" />
        <property name="version"            column="VERSION"                    type="integer" />
        <property name="versionReason"      column="VERSIONREASON"              type="string" />
    </class>
</hibernate-mapping>


When I try to deploy on my OC4J container, I get the following error

11/04/19 09:50:14 InitServlet - org.hibernate.MappingException: Could not read mappings from resource: previtc/model/task/PcTaskAssignee.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:484)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1443)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1411)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1392)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1368)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1288)
at previtc.Resources.init(Resources.java:156)
at previtc.controller.InitServlet.init(InitServlet.java:34)
at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:2354)
at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4795)
at com.evermind.server.http.HttpApplication.initPreloadServlets(HttpApplication.java:4889)
at com.evermind.server.http.HttpApplication.initDynamic(HttpApplication.java:1015)
at com.evermind.server.http.HttpApplication.<init>(HttpApplication.java:549)
at com.evermind.server.Application.getHttpApplication(Application.java:890)
at com.evermind.server.http.HttpServer.getHttpApplication(HttpServer.java:707)
at com.evermind.server.http.HttpSite.initApplications(HttpSite.java:625)
at com.evermind.server.http.HttpSite.setConfig(HttpSite.java:278)
at oracle.oc4j.admin.internal.WebApplicationBinder.bindWebApp(WebApplicationBinder.java:173)
at com.evermind.server.administration.DefaultApplicationServerAdministrator.bindWebApp(DefaultApplicationServerAdministrator.java:415)
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 com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:534)
Caused by: org.hibernate.MappingException: Could not parse mapping document in input stream
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:430)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:481)
... 26 more
Caused by: org.dom4j.DocumentException: Error on line 13 of document : Open quote is expected for attribute "name" associated with an element type "many-to-one". Nested exception: Open quote is exp
ected for attribute "name" associated with an element type "many-to-one".

at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:421)

Could anybody give me some hint of what I'm doing wrong please ? :D Thanks a lot in advance !


Top
 Profile  
 
 Post subject: Re: one to one XML mapping
PostPosted: Tue Apr 19, 2011 8:46 am 
Regular
Regular

Joined: Fri Jan 28, 2011 11:44 am
Posts: 117
You are using 2 different sets of quotes:

<key-property name="assignee" ...
<many-to-one name=task ...

The quotes around assignee are different from the quotes around task!!
The good ones are the first one. I don't even know what the second one correspond to ...


Top
 Profile  
 
 Post subject: Re: one to one XML mapping
PostPosted: Tue Apr 19, 2011 9:38 am 
Beginner
Beginner

Joined: Mon Apr 18, 2011 10:01 am
Posts: 20
You were right ! You were great noticing that particular ! But it's still not working... the compiler says

11/04/19 15:32:01 InitServlet - org.hibernate.MappingException: Repeated column in mapping for entity: previtc.model.task.PcTaskAssignee column: TASKID (should be mapped with insert="false" update="fa
lse")

at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:550)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:572)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:590)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:380)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:983)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1147)
at previtc.Resources.init(Resources.java:156)
at previtc.controller.InitServlet.init(InitServlet.java:34)
at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:2354)
at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4795)
at com.evermind.server.http.HttpApplication.initPreloadServlets(HttpApplication.java:4889)
at com.evermind.server.http.HttpApplication.initDynamic(HttpApplication.java:1015)
at com.evermind.server.http.HttpApplication.<init>(HttpApplication.java:549)
at com.evermind.server.Application.getHttpApplication(Application.java:890)
at com.evermind.server.http.HttpServer.getHttpApplication(HttpServer.java:707)
at com.evermind.server.http.HttpSite.initApplications(HttpSite.java:625)
at com.evermind.server.http.HttpSite.setConfig(HttpSite.java:278)
at oracle.oc4j.admin.internal.WebApplicationBinder.bindWebApp(WebApplicationBinder.java:173)
at com.evermind.server.administration.DefaultApplicationServerAdministrator.bindWebApp(DefaultApplicationServerAdministrator.java:415)
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 com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:534)
Web-App PreventiviITC_dev:PreventiviITC_dev (0.0.0.0/0.0.0.0:9700/PreventiviITC_dev) started...

where am I supposed to put insert="false" and update="false" ? Sorry I'm a bit noob... thanks for any advice


Top
 Profile  
 
 Post subject: Re: one to one XML mapping
PostPosted: Tue Apr 19, 2011 9:42 am 
Beginner
Beginner

Joined: Mon Apr 18, 2011 10:01 am
Posts: 20
I tried putting insert="false" and update="false" as follows :

Code:
<hibernate-mapping package="previtc.model.task">
    <class name="PcTaskAssignee" table="PC_TASKASSIGNEE" dynamic-update="true" dynamic-insert="true">
        <composite-id>
            <key-property name="taskId"  column="TASKID"  type="string"/>
            <key-property name="version" column="VERSION" type="double" />
            <key-property name="assignee" column="ASSIGNEE" type="string" />
        </composite-id>

        <property name="phone"        column="PHONE"       type="string" />
        <property name="email"        column="EMAIL"       type="string" />
        <property name="guid"         column="GUID"       type="string" />
        <property name="isGroup"      column="ISGROUP"    type="string" />

        <many-to-one name="task" class="previtc.model.task.PcTask"
            column="TASKID"
            cascade="all"  unique="true"
            [b]
            insert="false" update="false"
            [/b]
            />

    </class>
</hibernate-mapping>

but it still doesn't work ! The deploy complaints saying stuff such as the following :

org.hibernate.PropertyNotFoundException: Could not find a getter for task in class previtc.model.task.PcTaskAssignee
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)
at org.hibernate.mapping.Property.getGetter(Property.java:250)
at org.hibernate.tuple.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:255)
at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:121)
at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:215)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1154)
at previtc.Resources.init(Resources.java:156)
at previtc.controller.InitServlet.init(InitServlet.java:34)
at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:2354)
at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4795)
at com.evermind.server.http.HttpApplication.initPreloadServlets(HttpApplication.java:4889)
at com.evermind.server.http.HttpApplication.initDynamic(HttpApplication.java:1015)
at com.evermind.server.http.HttpApplication.<init>(HttpApplication.java:549)
at com.evermind.server.Application.getHttpApplication(Application.java:890)
at com.evermind.server.http.HttpServer.getHttpApplication(HttpServer.java:707)
at com.evermind.server.http.HttpSite.initApplications(HttpSite.java:625)
at com.evermind.server.http.HttpSite.setConfig(HttpSite.java:278)
at com.evermind.server.http.HttpServer.setSites(HttpServer.java:278)
at com.evermind.server.http.HttpServer.setConfig(HttpServer.java:179)
at com.evermind.server.ApplicationServer.initializeHttp(ApplicationServer.java:2394)
at com.evermind.server.ApplicationServer.setConfig(ApplicationServer.java:1551)
at com.evermind.server.ApplicationServerLauncher.run(ApplicationServerLauncher.java:92)
at java.lang.Thread.run(Thread.java:


Top
 Profile  
 
 Post subject: Re: one to one XML mapping
PostPosted: Tue Apr 19, 2011 11:33 am 
Regular
Regular

Joined: Fri Jan 28, 2011 11:44 am
Posts: 117
According to your mapping you should have a property task of type PcTask in the class PcTaskAssignee
But I don't see it in your previous post ... so add it with the corresponding getter/setter


Top
 Profile  
 
 Post subject: Re: one to one XML mapping
PostPosted: Wed Apr 20, 2011 3:26 am 
Beginner
Beginner

Joined: Mon Apr 18, 2011 10:01 am
Posts: 20
Thank you for your answer ! But who's wrong it's me ! I'm trying to achieve something else ! I've defined on the Oracle schema on my Database a new constraint which force my PcTask.taskId to be foreign key for PcTaskAssignee.taskId , and also PcTask.taskId must be primary key for PcTask, and PcTaskAssignee.taskId must be primary key for PcTaskAssignee...

So there must be something conceptually wrong in my thoughts... I will check it out! If you may have some suggestions, please they would be welcome !

Thanks again !


Top
 Profile  
 
 Post subject: Re: one to one XML mapping
PostPosted: Wed Apr 20, 2011 4:42 am 
Regular
Regular

Joined: Fri Jan 28, 2011 11:44 am
Posts: 117
The problem is not with your datamodel, everything you said above is true.
You have a column TASKID which is Primary Key for the PcTask Table.
Then you have column TASKID which is part of the Composite Key for PcTaskAssignee Table. And in this case, the column is also Foreign Key for a PcTask element ...

As far as I can see, this is correct and this is what you want.
The problem here is only that your java classes doesn't match your mapping!
In your mapping you define an unidirectionnal one-to-one from PcTaskAssignee to PcTask, you just need to recreate this mapping in you java classes ...


Top
 Profile  
 
 Post subject: Re: one to one XML mapping
PostPosted: Wed Apr 20, 2011 5:38 am 
Beginner
Beginner

Joined: Mon Apr 18, 2011 10:01 am
Posts: 20
Just to make it work, I had removed the mapping and focused on other use cases . Result : I've broken my web app, and I really can't see why. The original problem is not the problem anymore: my OC4J won't start , saying

11/04/20 10:13:47 InitServlet - org.hibernate.MappingException: Could not read mappings from resource: previtc/model/task/PcTaskAssignee.hbm.xml at org.hibernate.cfg.Configuration.addResource(Configuration.java:484)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1443)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1411)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1392)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1368)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1288)
at previtc.Resources.init(Resources.java:156)
at previtc.controller.InitServlet.init(InitServlet.java:34)
at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:2354)
at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4795)
at com.evermind.server.http.HttpApplication.initPreloadServlets(HttpApplication.java:4889)
at com.evermind.server.http.HttpApplication.initDynamic(HttpApplication.java:1015)
at com.evermind.server.http.HttpApplication.<init>(HttpApplication.java:549)
at com.evermind.server.Application.getHttpApplication(Application.java:890)
at com.evermind.server.http.HttpServer.getHttpApplication(HttpServer.java:707)
at com.evermind.server.http.HttpSite.initApplications(HttpSite.java:625)
at com.evermind.server.http.HttpSite.setConfig(HttpSite.java:278)
at oracle.oc4j.admin.internal.WebApplicationBinder.bindWebApp(WebApplicationBinder.java:173)
at com.evermind.server.administration.DefaultApplicationServerAdministrator.bindWebApp(DefaultApplicationServerAdministrator.java:415)
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 com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:534)
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:424)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:481)
... 26 more
Caused by: org.xml.sax.SAXParseException: Attribute "insert" must be declared for element type "key-property".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:421)

it is mandatory to fix the problem before worrying about the many-to-one stuff! :( as long as you've been the only one giving me some hints, I'm telling you, I'm wondering why this exception raised , considering the same things said before, apart from removing the one to many mapping we said, putting my xml back to the roots :

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="previtc.model.task">
    <class name="previtc.model.task.PcTaskAssignee" table="PC_TASKASSIGNEE" dynamic-update="true" dynamic-insert="true">
        <composite-id>
            <key-property name="taskId"   type="string" column="TASKID"  />           
            <key-property name="version"  type="double" column="VERSION" />
            <key-property name="assignee" type="string" column="ASSIGNEE"/>
        </composite-id>
        <property name="phone"      type="string"       column="PHONE"  />
        <property name="email"      type="string"       column="EMAIL"  />
        <property name="guid"       type="string"       column="GUID"   />
        <property name="isGroup"    type="string"       column="ISGROUP"/>
    </class>
</hibernate-mapping>


and

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="previtc.model.task">
    <class name="PcTask" table="PC_TASK" dynamic-update="true" dynamic-insert="true">
        <id name="taskId" column="TASKID" type="string">
            <generator class="sequence">
                <param name="sequence">PC_TASK_ID_SEQ</param>
            </generator>
        </id>
        <property name="taskNumber"         column="TASKNUMBER"                 type="double" /> 
        <property name="acquiredBy"         column="ACQUIREDBY"                 type="string" />
        <property name="approvers"          column="APPROVERS"                  type="string" />
        <property name="comment1"           column="COMMENT1"                   type="string" />
        <property name="comment2"           column="COMMENT2"                   type="string" />
        <property name="comment3"           column="COMMENT3"                   type="string" />
        <property name="comment4"           column="COMMENT4"                   type="string" />
        <property name="comment5"           column="COMMENT5"                   type="string" />
        <property name="conclusion"         column="CONCLUSION"                 type="string" />
        <property name="createdDate"        column="CREATEDDATE"                type="date" />
        <property name="creator"            column="CREATOR"                    type="string" />
        <property name="domainId"           column="DOMAINID"                   type="string" />
        <property name="expirationDate"     column="EXPIRATIONDATE"             type="date" />
        <property name="expirationDuration" column="EXPIRATIONDURATION"         type="string" />
        <property name="flexDate1"          column="FLEXDATE1"                  type="date" />
        <property name="flexDate2"          column="FLEXDATE2"                  type="date" />
        <property name="flexDate3"          column="FLEXDATE3"                  type="date" />
        <property name="flexDouble1"        column="FLEXDOUBLE1"                type="double" />
        <property name="flexDouble2"        column="FLEXDOUBLE2"                type="double" />
        <property name="flexLong1"          column="FLEXLONG1"                  type="double" />
        <property name="flexLong2"          column="FLEXLONG2"                  type="double" />
        <property name="flexString1"        column="FLEXSTRING1"                type="string" />
        <property name="flexString2"        column="FLEXSTRING2"                type="string" />
        <property name="flexString3"        column="FLEXSTRING3"                type="string" />
        <property name="flexString4"        column="FLEXSTRING4"                type="string" />
        <property name="identificationKey"  column="IDENTIFICATIONKEY"          type="string" />
        <property name="instanceId"         column="INSTANCEID"                 type="string" />
        <property name="isGroup"            column="ISGROUP"                    type="string" />
        <property name="isHassubTask"       column="ISHASSUBTASK"               type="string" />
        <property name="modifyDate"         column="MODIFYDATE"                 type="date"   />
        <property name="notm"               column="NOTM"                       type="integer"/>
        <property name="owner"              column="OWNER"                      type="string" />
        <property name="pattern"            column="PATTERN"                    type="string" />
        <property name="priority"           column="PRIORITY"                   type="integer"/>
        <property name="processId"          column="PROCESSID"                  type="string" />
        <property name="processName"        column="PROCESSNAME"                type="string" />
        <property name="processOwner"       column="PROCESSOWNER"               type="string" />
        <property name="processVersion"     column="PROCESSVERSION"             type="string" />
        <property name="state"              column="STATE"                      type="string" />
        <property name="substate"           column="SUBSTATE"                   type="string" />
        <property name="systemString1"      column="SYSTEMSTRING1"              type="string" />
        <property name="systemString2"      column="SYSTEMSTRING2"              type="string" />
        <property name="systemString3"      column="SYSTEMSTRING3"              type="string" />
        <property name="taskGroupId"        column="TASKGROUPID"                type="string" />
        <property name="taskType"           column="TASKTYPE"                   type="string" />
        <property name="title"              column="TITLE"                      type="string" />
        <property name="updatedBy"          column="UPDATEDBY"                  type="string" />
        <property name="version"            column="VERSION"                    type="integer" />
        <property name="versionReason"      column="VERSIONREASON"              type="string" />
    </class>
</hibernate-mapping>


do you have any ideas ? I'm sorry to bother you, but I'm really stuck!


Top
 Profile  
 
 Post subject: Re: one to one XML mapping
PostPosted: Wed Apr 20, 2011 5:49 am 
Regular
Regular

Joined: Fri Jan 28, 2011 11:44 am
Posts: 117
In your mapping change

Code:
<class name="previtc.model.task.PcTaskAssignee" ...


into

Code:
<class name="PcTaskAssignee" ...


You already specified the package so I think hibernate will get confused if you keep the full path


Top
 Profile  
 
 Post subject: Re: one to one XML mapping
PostPosted: Wed Apr 20, 2011 5:59 am 
Beginner
Beginner

Joined: Mon Apr 18, 2011 10:01 am
Posts: 20
But I changed right in front of the problem, cause it stopped working ... now I changed it back following your hint , but it still breaks...

and then in the stack trace says Attribute "insert" must be declared for element type "key-property". ... it's like oc4j "cached" when I tried to put external mapping , and now he could not flush his memory , refraining the old error, even if I changed hbm.xml file . Indeed , I checked on my deploy directory, and I can see that the files are uploaded there, I find the new version for that!

This is crazy...


Top
 Profile  
 
 Post subject: Re: one to one XML mapping
PostPosted: Wed Apr 20, 2011 9:35 am 
Beginner
Beginner

Joined: Mon Apr 18, 2011 10:01 am
Posts: 20
Thank you, I solved the problem mentioned above deleting all the content in folders "application" and "application-depoyments" in the OC4J directory.

How about what we were saying before this ? I should just add a
Code:
PcTask pc_task
attribute in my PcTaskAssignee class and put in my .xml

Code:
        <many-to-one name="task" class="previtc.model.task.PcTask"
            column="TASKID"
            cascade="all"  unique="true"
            insert="false" update="false"
            />


right? Thank you...


Top
 Profile  
 
 Post subject: Re: one to one XML mapping
PostPosted: Thu Apr 21, 2011 5:41 am 
Beginner
Beginner

Joined: Mon Apr 18, 2011 10:01 am
Posts: 20
Ok , I managed to fix it, and configure the mapping. Thanks to everybody who supported this. Should I give some feedback to the user who solved the most of my problems ? Thanks again.


Top
 Profile  
 
 Post subject: Re: one to one XML mapping
PostPosted: Fri Apr 22, 2011 10:08 am 
Regular
Regular

Joined: Fri Jan 28, 2011 11:44 am
Posts: 117
How did you fix it?


Top
 Profile  
 
 Post subject: Re: one to one XML mapping
PostPosted: Wed Apr 27, 2011 8:45 am 
Beginner
Beginner

Joined: Mon Apr 18, 2011 10:01 am
Posts: 20
Well, I did not want to have any PcTaskAssignee object into my PcTask, nor any PcTask in PcTaskAssignee, I just wanted to match PcTask primary key to PcTaskAssignee primary key, so I configured it on my Oracle Database, and I get thrown an exception every time the application tries to insert orphaned records in the PcTaskAssignee, indeed if there's no PcTask , thou shall not be assignee for a non existing task.

Otherwise here in italy everybody would get a phantom task and never work again . No just kidding :D


Top
 Profile  
 
 Post subject: Re: one to one XML mapping
PostPosted: Thu Apr 28, 2011 4:59 am 
Newbie

Joined: Thu Apr 28, 2011 4:37 am
Posts: 1
Looking for solution.

_________________
Keurig B60
sinus infection treatment
Paleo snacks
filecure review


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

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.