-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem with deleting elements of composite collection
PostPosted: Mon Oct 18, 2004 9:13 am 
Newbie

Joined: Thu Aug 05, 2004 4:45 am
Posts: 3
Hello!!!

I'm using Hibernate 2.1.6 with with Postgresql 7.3. I have a problem with following code fragment:

Code:
            final Iterator iter = empMcnInfos.iterator();
            EmployeeFunctionInfo empInfo = null;
            int deleted = 0;
            while (iter.hasNext()) {
                empInfo = (EmployeeFunctionInfo) iter.next();

                if (getLogger().isDebugEnabled()) {
                    final String message = "Deleting employee function = "
                            + empInfo.getMachineFunction()
                            + " for machine with system id = "
                            + empInfo.getMachineSystemId()
                            + "and employee with system id = "
                            + empInfo.getEmployeeSystemId();
                    debug(message);
                }
               
                                deleted = hbmSession
                                        .delete(
                                                "select emf from com.mrt.vend.server.model.Employee emp join emp.machineFunctions emf "
                                                        + "where emf.machine.id = ? and emf.employeeFunction = ? and emp.id = ? and emp.operator.id = ?",
                                                new Object[] {
                                                        empInfo.getMachineSystemId(),
                                                        empInfo.getMachineFunction(),
                                                        getSystemIdFormat().parse(
                                                                empInfo.getEmployeeSystemId()),
                                                        operId },
                                                new Type[] {
                                                        Hibernate.LONG,
                                                        Hibernate
                                                                .custom(EmployeeFunctionHbm .class),
                                                        Hibernate.LONG, Hibernate.LONG });
               
                                if (deleted != 1) {
                                    if (getLogger().isWarnEnabled()) {
                                        final String message = "Deleted " + deleted
                                                + " machine functions";
                                        warn(message);
                                    }
                                }

            }

and I got following exception:
Quote:
18 paź 2004 13:49 [RMI TCP Connection(2)-192.168.0.20] DEBUG net.sf.hibernate.transaction.JDBCTransaction - current autocommit status:false
18 paź 2004 13:49 [RMI TCP Connection(2)-192.168.0.20] DEBUG /mrt-vend-server/employee-manager - Deleting employee function = EmployeeFunction[N
aprawa=4] for machine with system id = 1and employee with system id = 00001
18 paź 2004 13:49 [RMI TCP Connection(2)-192.168.0.20] DEBUG net.sf.hibernate.impl.SessionImpl - delete: select emf from com.mrt.vend.server.mod
el.Employee emp join emp.machineFunctions emf where emf.machine.id = ? and emf.employeeFunction = ? and emp.id = ? and emp.operator.id = ?
18 paź 2004 13:49 [RMI TCP Connection(2)-192.168.0.20] DEBUG net.sf.hibernate.impl.SessionImpl - parameters: 1, EmployeeFunction[Naprawa=4], 1,
1
18 paź 2004 13:49 [RMI TCP Connection(2)-192.168.0.20] DEBUG net.sf.hibernate.impl.SessionImpl - find: select emf from com.mrt.vend.server.model
.Employee emp join emp.machineFunctions emf where emf.machine.id = ? and emf.employeeFunction = ? and emp.id = ? and emp.operator.id = ?
18 paź 2004 13:49 [RMI TCP Connection(2)-192.168.0.20] DEBUG net.sf.hibernate.engine.QueryParameters - parameters: [1, EmployeeFunction[Naprawa=
4], 1, 1]
18 paź 2004 13:49 [RMI TCP Connection(2)-192.168.0.20] DEBUG net.sf.hibernate.hql.QueryTranslator - compiling query
18 paź 2004 13:49 [RMI TCP Connection(2)-192.168.0.20] FATAL /mrt-vend-server/employee-manager - Failed to commit transaction
net.sf.hibernate.QueryException: could not resolve property: id of: com.mrt.vend.server.model.EmployeeMachineFunction [select emf from com.mrt.v
end.server.model.Employee emp join emp.machineFunctions emf where emf.machine.id = ? and emf.employeeFunction = ? and emp.id = ? and emp.operato
r.id = ?]
at net.sf.hibernate.persister.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:38)
at net.sf.hibernate.collection.AbstractCollectionPersister.toType(AbstractCollectionPersister.java:663)
at net.sf.hibernate.hql.PathExpressionParser.getPropertyType(PathExpressionParser.java:249)
at net.sf.hibernate.hql.PathExpressionParser.end(PathExpressionParser.java:288)
at net.sf.hibernate.hql.SelectPathExpressionParser.end(SelectPathExpressionParser.java:14)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
at net.sf.hibernate.hql.SelectParser.token(SelectParser.java:170)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.ClauseParser.end(ClauseParser.java:114)
at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:143)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:294)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1562)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1533)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1521)
at net.sf.hibernate.impl.SessionImpl.delete(SessionImpl.java:1668)
at com.mrt.vend.server.service.EmployeeManagerImpl.unregisterEmployeeFunctions(EmployeeManagerImpl.java:334)
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 org.apache.avalon.activation.impl.ApplianceInvocationHandler.invoke(ApplianceInvocationHandler.java:129)
at $Proxy14.unregisterEmployeeFunctions(Unknown Source)
at com.mrt.vend.server.service.RemoteFacadeImpl.unregisterEmployeeFunctions(RemoteFacadeImpl.java:276)
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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
18 paź 2004 13:49 [RMI TCP Connection(2)-192.168.0.20] DEBUG net.sf.hibernate.transaction.JDBCTransaction - rollback
18 paź 2004 13:49 [RMI TCP Connection(2)-192.168.0.20] DEBUG net.sf.hibernate.impl.SessionImpl - transaction completion


and my hibernate mapping:
Code:
<?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>
    <class
        name="com.mrt.vend.server.model.Employee"
        table="employees"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="emp_id"
            type="java.lang.Long"
            unsaved-value="null"
        >
            <generator class="sequence">
                <param name="sequence">employees_id_sequence</param>
            </generator>
        </id>

        <set
            name="machineFunctions"
            table="employee_functions"
            lazy="false"
            inverse="false"
            cascade="none"
            sort="unsorted"
        >

              <key
                  column="emf_emp_id"
              >
              </key>

              <composite-element
                  class="com.mrt.vend.server.model.EmployeeMachineFunction"
              >
        <property
            name="employeeFunction"
            type="com.mrt.vend.server.model.ext.EmployeeFunctionHbm"
            update="true"
            insert="true"
            access="property"
            column="emf_func"
            length="16"
            not-null="true"/>

        <many-to-one
            name="machine"
            class="com.mrt.vend.server.model.Machine"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="emf_mcn_id"
        />

              </composite-element>

        </set>

        <property
            name="active"
            type="java.lang.Boolean"
            update="true"
            insert="true"
            access="property"
            column="emp_active"
            not-null="true"
        />

        <many-to-one
            name="operator"
            class="com.mrt.vend.server.model.Operator"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="emp_opr_id"
            not-null="true"
        />

        <property
            name="phoneNumber"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="emp_phone"
            length="32"
            not-null="true"
        />

        <many-to-one
            name="currentActivity"
            class="com.mrt.vend.server.model.EmployeeActivity"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="emp_ema_id"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Employee.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>


Can anyone help me?

Thanks.


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

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.