-->
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.  [ 5 posts ] 
Author Message
 Post subject: table has no column named elt (DEFAULT_COLUMN_ELEMENT_NAME)
PostPosted: Wed Mar 03, 2004 6:53 pm 
Beginner
Beginner

Joined: Wed Oct 29, 2003 11:52 am
Posts: 37
Location: Gothenburg, Sweden
My guess is that I've ran accross a bug.

Hibernate: 2.1.2
DBMS: Postgresql 7.4

Code:
org.postgresql.util.PSQLException: ERROR: column networkcab0_.elt does not exist


And very true, there's no such column, and there's no mentioning of the three letters ent in any of the mapping files nor java source files. All I find is the "Constant Field Value":
Code:
net.sf.hibernate.mapping.Collection
public static final String    DEFAULT_ELEMENT_COLUMN_NAME    "elt"


The query: (hold on)
Code:
select networkcab0_.elt as elt__, networkcab0_.computer as computer__, networkcab1_.id as id0_, networkcab1_.connectionType as connecti2_0_, networkcab1_.note as note0_, networkcab1_.cableType as cableType0_, networkcab1_.computer as computer0_, networkcab1_.outlet as outlet0_, networkcab1_.port as port0_, networkcab1_.downlink as downlink0_, networkcab2_.id as id1_, networkcab2_.name as name1_, networkcab2_.description as descript3_1_, computer3_.id as id2_, computer3_.hostname as hostname2_, computer3_.NVG as NVG2_, computer3_.visible as visible2_, computer3_.note as note2_, computer3_.mac as mac2_, computer3_.ipv4 as ipv42_, computer3_.code as code2_, computer3_.owner as owner2_, computer3_.firewallMode as firewal10_2_, computer3_.status as status2_, ipv44_.id as id3_, ipv44_.reserved as reserved3_, ipv44_.private as private3_, ipv44_.assignedAt as assignedAt3_, ipv44_.address as address3_, person5_.id as id4_, person5_.name as name4_, person5_.language as language4_, person5_.eMailAddress as eMailAdd4_4_, person5_.telephone as telephone4_, person5_.homepage as homepage4_, person5_.education as education4_, person5_.username as username4_, person5_.password as password4_, person5_.lastLogin as lastLogin4_, person5_.thisLogin as thisLogin4_, person5_.note as note4_, person5_.flat as flat4_, person5_.status as status4_, person5_.visibilityMode as visibil15_4_, flat6_.id as id5_, flat6_.floor as floor5_, flat6_.name as name5_, flat6_.description as descript4_5_, flat6_.note as note5_, flat6_.staircase as staircase5_, staircase7_.id as id6_, staircase7_.name as name6_, staircase7_.description as descript3_6_, staircase7_.livingArea as livingArea6_, livingarea8_.id as id7_, livingarea8_.name as name7_, livingarea8_.description as descript3_7_, status9_.id as id8_, status9_.name as name8_, status9_.description as descript3_8_, visibility10_.id as id9_, visibility10_.name_sv as name_sv9_, visibility10_.name_en as name_en9_, firewallmo11_.id as id10_, firewallmo11_.name_sv as name_sv10_, firewallmo11_.name_en as name_en10_, status12_.id as id11_, status12_.name as name11_, status12_.description as descript3_11_, outlet13_.id as id12_, outlet13_.name as name12_, outlet13_.note as note12_, outlet13_.flat as flat12_, outlet13_.wiringCloset as wiringCl5_12_, wiringclos14_.id as id13_, wiringclos14_.name as name13_, wiringclos14_.floor as floor13_, wiringclos14_.officialName as official4_13_, wiringclos14_.description as descript5_13_, wiringclos14_.note as note13_, wiringclos14_.staircase as staircase13_, switchport15_.id as id14_, switchport15_.name as name14_, switchport15_.immortal as immortal14_, switchport15_.switch as switch14_, switchport15_.portType as portType14_, switch16_.id as id15_, switch16_.name as name15_, switch16_.note as note15_, switch16_.mac as mac15_, switch16_.switchModel as switchMo5_15_, switch16_.wiringCloset as wiringCl6_15_, switch16_.ipv4 as ipv415_, switchmode17_.id as id16_, switchmode17_.name as name16_, switchmode17_.snmpName as snmpName16_, switchmode17_.snmpSupported as snmpSupp4_16_, wiringclos18_.id as id17_, wiringclos18_.name as name17_, wiringclos18_.floor as floor17_, wiringclos18_.officialName as official4_17_, wiringclos18_.description as descript5_17_, wiringclos18_.note as note17_, wiringclos18_.staircase as staircase17_, ipv419_.id as id18_, ipv419_.reserved as reserved18_, ipv419_.private as private18_, ipv419_.assignedAt as assignedAt18_, ipv419_.address as address18_, porttype20_.id as id19_, porttype20_.name as name19_, porttype20_.description as descript3_19_, networkcab21_.id as id20_, networkcab21_.computer as computer20_, networkcab21_.port as port20_, networkcab21_.note as note20_, networkcab21_.cableType as cableType20_, networkcab22_.id as id21_, networkcab22_.name as name21_, networkcab22_.description as descript3_21_

from networkCables networkcab0_
inner join NetworkCables networkcab1_ on networkcab0_.elt=networkcab1_.id
left outer join NetworkCableTypes networkcab2_ on networkcab1_.cableType=networkcab2_.id
left outer join Computers computer3_ on networkcab1_.computer=computer3_.id
left outer join IPv4Addresses ipv44_ on computer3_.ipv4=ipv44_.id
left outer join Persons person5_ on computer3_.owner=person5_.id
left outer join Flats flat6_ on person5_.flat=flat6_.id
left outer join Staircases staircase7_ on flat6_.staircase=staircase7_.id
left outer join LivingAreas livingarea8_ on staircase7_.livingArea=livingarea8_.id
left outer join Statuses status9_ on person5_.status=status9_.id
left outer join VisibilityModes visibility10_ on person5_.visibilityMode=visibility10_.id
left outer join FirewallModes firewallmo11_ on computer3_.firewallMode=firewallmo11_.id
left outer join Statuses status12_ on computer3_.status=status12_.id
left outer join Outlets outlet13_ on networkcab1_.outlet=outlet13_.id
left outer join WiringClosets wiringclos14_ on outlet13_.wiringCloset=wiringclos14_.id
left outer join SwitchPorts switchport15_ on networkcab1_.port=switchport15_.id
left outer join Switches switch16_ on switchport15_.switch=switch16_.id
left outer join SwitchModels switchmode17_ on switch16_.switchModel=switchmode17_.id
left outer join WiringClosets wiringclos18_ on switch16_.wiringCloset=wiringclos18_.id
left outer join IPv4Addresses ipv419_ on switch16_.ipv4=ipv419_.id
left outer join PortTypes porttype20_ on switchport15_.portType=porttype20_.id
left outer join NetworkCables networkcab21_ on switchport15_.id=networkcab21_.port
left outer join NetworkCableTypes networkcab22_ on networkcab21_.cableType=networkcab22_.id

where networkcab0_.computer=? 


Rewriting it replacing networkcab0_.elt to .id at least is syntactically correct:
Code:
select networkcab0_.id as elt__, networkcab0_.computer as computer__, networkcab1_.id as id0_, networkcab1_.connectionType as connecti2_0_, networkcab1_.note as note0_, networkcab1_.cableType as cableType0_, networkcab1_.computer as computer0_, networkcab1_.outlet as outlet0_, networkcab1_.port as port0_, networkcab1_.downlink as downlink0_, networkcab2_.id as id1_, networkcab2_.name as name1_, networkcab2_.description as descript3_1_, computer3_.id as id2_, computer3_.hostname as hostname2_, computer3_.NVG as NVG2_, computer3_.visible as visible2_, computer3_.note as note2_, computer3_.mac as mac2_, computer3_.ipv4 as ipv42_, computer3_.code as code2_, computer3_.owner as owner2_, computer3_.firewallMode as firewal10_2_, computer3_.status as status2_, ipv44_.id as id3_, ipv44_.reserved as reserved3_, ipv44_.private as private3_, ipv44_.assignedAt as assignedAt3_, ipv44_.address as address3_, person5_.id as id4_, person5_.name as name4_, person5_.language as language4_, person5_.eMailAddress as eMailAdd4_4_, person5_.telephone as telephone4_, person5_.homepage as homepage4_, person5_.education as education4_, person5_.username as username4_, person5_.password as password4_, person5_.lastLogin as lastLogin4_, person5_.thisLogin as thisLogin4_, person5_.note as note4_, person5_.flat as flat4_, person5_.status as status4_, person5_.visibilityMode as visibil15_4_, flat6_.id as id5_, flat6_.floor as floor5_, flat6_.name as name5_, flat6_.description as descript4_5_, flat6_.note as note5_, flat6_.staircase as staircase5_, staircase7_.id as id6_, staircase7_.name as name6_, staircase7_.description as descript3_6_, staircase7_.livingArea as livingArea6_, livingarea8_.id as id7_, livingarea8_.name as name7_, livingarea8_.description as descript3_7_, status9_.id as id8_, status9_.name as name8_, status9_.description as descript3_8_, visibility10_.id as id9_, visibility10_.name_sv as name_sv9_, visibility10_.name_en as name_en9_, firewallmo11_.id as id10_, firewallmo11_.name_sv as name_sv10_, firewallmo11_.name_en as name_en10_, status12_.id as id11_, status12_.name as name11_, status12_.description as descript3_11_, outlet13_.id as id12_, outlet13_.name as name12_, outlet13_.note as note12_, outlet13_.flat as flat12_, outlet13_.wiringCloset as wiringCl5_12_, wiringclos14_.id as id13_, wiringclos14_.name as name13_, wiringclos14_.floor as floor13_, wiringclos14_.officialName as official4_13_, wiringclos14_.description as descript5_13_, wiringclos14_.note as note13_, wiringclos14_.staircase as staircase13_, switchport15_.id as id14_, switchport15_.name as name14_, switchport15_.immortal as immortal14_, switchport15_.switch as switch14_, switchport15_.portType as portType14_, switch16_.id as id15_, switch16_.name as name15_, switch16_.note as note15_, switch16_.mac as mac15_, switch16_.switchModel as switchMo5_15_, switch16_.wiringCloset as wiringCl6_15_, switch16_.ipv4 as ipv415_, switchmode17_.id as id16_, switchmode17_.name as name16_, switchmode17_.snmpName as snmpName16_, switchmode17_.snmpSupported as snmpSupp4_16_, wiringclos18_.id as id17_, wiringclos18_.name as name17_, wiringclos18_.floor as floor17_, wiringclos18_.officialName as official4_17_, wiringclos18_.description as descript5_17_, wiringclos18_.note as note17_, wiringclos18_.staircase as staircase17_, ipv419_.id as id18_, ipv419_.reserved as reserved18_, ipv419_.private as private18_, ipv419_.assignedAt as assignedAt18_, ipv419_.address as address18_, porttype20_.id as id19_, porttype20_.name as name19_, porttype20_.description as descript3_19_, networkcab21_.id as id20_, networkcab21_.computer as computer20_, networkcab21_.port as port20_, networkcab21_.note as note20_, networkcab21_.cableType as cableType20_, networkcab22_.id as id21_, networkcab22_.name as name21_, networkcab22_.description as descript3_21_

from networkCables networkcab0_
inner join NetworkCables networkcab1_ on networkcab0_.id=networkcab1_.id
left outer join NetworkCableTypes networkcab2_ on networkcab1_.cableType=networkcab2_.id
left outer join Computers computer3_ on networkcab1_.computer=computer3_.id
left outer join IPv4Addresses ipv44_ on computer3_.ipv4=ipv44_.id
left outer join Persons person5_ on computer3_.owner=person5_.id
left outer join Flats flat6_ on person5_.flat=flat6_.id
left outer join Staircases staircase7_ on flat6_.staircase=staircase7_.id
left outer join LivingAreas livingarea8_ on staircase7_.livingArea=livingarea8_.id
left outer join Statuses status9_ on person5_.status=status9_.id
left outer join VisibilityModes visibility10_ on person5_.visibilityMode=visibility10_.id
left outer join FirewallModes firewallmo11_ on computer3_.firewallMode=firewallmo11_.id
left outer join Statuses status12_ on computer3_.status=status12_.id
left outer join Outlets outlet13_ on networkcab1_.outlet=outlet13_.id
left outer join WiringClosets wiringclos14_ on outlet13_.wiringCloset=wiringclos14_.id
left outer join SwitchPorts switchport15_ on networkcab1_.port=switchport15_.id
left outer join Switches switch16_ on switchport15_.switch=switch16_.id
left outer join SwitchModels switchmode17_ on switch16_.switchModel=switchmode17_.id
left outer join WiringClosets wiringclos18_ on switch16_.wiringCloset=wiringclos18_.id
left outer join IPv4Addresses ipv419_ on switch16_.ipv4=ipv419_.id
left outer join PortTypes porttype20_ on switchport15_.portType=porttype20_.id
left outer join NetworkCables networkcab21_ on switchport15_.id=networkcab21_.port
left outer join NetworkCableTypes networkcab22_ on networkcab21_.cableType=networkcab22_.id

where networkcab0_.computer=?;


But how the heck did elt get there?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 9:45 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The error is in your mapping. Show us.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 10:18 pm 
Beginner
Beginner

Joined: Wed Oct 29, 2003 11:52 am
Posts: 37
Location: Gothenburg, Sweden
The NetworkCable table:
Code:
                               Table "public.networkcables"
     Column     |  Type   |                           Modifiers                           
----------------+---------+---------------------------------------------------------------
id             | integer | not null default nextval('public.networkcables_id_seq'::text)
cabletype      | integer | not null
note           | text    |
connectiontype | integer | not null
computer       | integer |
outlet         | integer |
port           | integer |
downlink       | integer |


cabletype references this table:
Code:
                                    Table "public.networkcabletypes"
   Column    |         Type         |                             Modifiers                             
-------------+----------------------+-------------------------------------------------------------------
id          | integer              | not null default nextval('public.networkcabletypes_id_seq'::text)
name        | character varying(8) | not null
description | text                 |


NetworkCable.hbm.xml:
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="se.csbnet.nvg.sad.beans.NetworkCable" table="NetworkCables"
           discriminator-value="not null">
        <id name="id" column="id">
            <generator class="sequence">
                <param name="sequence">NetworkCables_id_seq</param>
            </generator>
        </id>
        <discriminator column="connectionType" type="integer" />

        <property name="note" type="text" />

        <many-to-one name="cableType" not-null="true" />

        <subclass name="se.csbnet.nvg.sad.beans.NetworkCableComputerOutlet"
                  discriminator-value="1">
            <many-to-one name="computer" not-null="true"/>
            <many-to-one name="outlet" not-null="true"/>
        </subclass>
        <subclass name="se.csbnet.nvg.sad.beans.NetworkCableComputerPort"
                  discriminator-value="2">
            <many-to-one name="computer" not-null="true"/>
            <many-to-one name="port" not-null="true"/>
        </subclass>
        <subclass name="se.csbnet.nvg.sad.beans.NetworkCableOutletPort"
                  discriminator-value="3">
            <many-to-one name="outlet" not-null="true"/>
            <many-to-one name="port" not-null="true"/>
        </subclass>
        <subclass name="se.csbnet.nvg.sad.beans.NetworkCablePortPort"
                  discriminator-value="4">
            <many-to-one name="uplink" column="port" not-null="true"/>
            <many-to-one name="downlink" not-null="true"/>
        </subclass>
    </class>
</hibernate-mapping>


PortPort works. I'm storing the Sesion in Lifecycle.onLoad() and use it later when needed. The bean is loaded using Hibernate.load(Class, Serializable).

In Computer.java and Outlet.java I try to use a Set. The mapping files looks like this:
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="se.csbnet.nvg.sad.beans.Computer" table="Computers">
        <id name="id" column="id">
            <generator class="sequence">
                <param name="sequence">Computers_id_seq</param>
            </generator>
        </id>
        <!-- properties here -->

        <!-- cables
        -->
        <set name="networkCables" lazy="true" >
            <key column="computer" />
            <many-to-many class="se.csbnet.nvg.sad.beans.NetworkCable" />
        </set>
    </class>
</hibernate-mapping>


Outlet.hbm.xml looks pretty much the same:
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="se.csbnet.nvg.sad.beans.Outlet" table="Outlets">
        <id name="id" column="id">
            <generator class="sequence">
                <param name="sequence">Outlets_id_seq</param>
            </generator>
        </id>

        <property name="name" not-null="true" />
        <property name="note" type="text" />

        <many-to-one name="flat" not-null="true" />
        <many-to-one name="wiringCloset" not-null="true" />

        <!--
        -->
        <set name="networkCables" lazy="true">
            <key column="outlet"/>
            <many-to-many class="se.csbnet.nvg.sad.beans.NetworkCable" />
        </set>
    </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 10:36 pm 
Beginner
Beginner

Joined: Wed Oct 29, 2003 11:52 am
Posts: 37
Location: Gothenburg, Sweden
changing to <one-to-many> works for Outlet, but for Computers Hibernate issues update NetworkCable set computer=null where computer=?.

Appologies for posting when I really should sleep instead.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 10:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
<set name="networkCables" lazy="true" >
<key column="computer" />
<many-to-many class="se.csbnet.nvg.sad.beans.NetworkCable" />
</set>


And


<set name="networkCables" lazy="true">
<key column="outlet"/>
<many-to-many class="se.csbnet.nvg.sad.beans.NetworkCable" />
</set>


Define the set elements using many-to-many. Where's the association table definitionin the mappings above to tell hibernate where those many-to-many associations are persisted?


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