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: Inner join in mapping file using <join table=""
PostPosted: Fri Apr 25, 2008 4:43 am 
Newbie

Joined: Fri Apr 25, 2008 4:21 am
Posts: 1
I'm trying to perform an inner join in a mapping file for the SNMP_TRAP_LOG table to provide the resolved machine name from MACHINES table. There is no FK between the tables but the mach_id in SNMP_TRAP_LOG is the machine PK in the MACHINES table.

In SQL i would use:

SELECT [id] as [id],
[writetime] as [writetime],
[mach_id] as [mach_id],
[port_id] as [port_id],
[timeslot] as [timeslot],
[trap_oid] as [trap],
[severity] as [severity],
[message] as [message],
[source_app] as [source],
[open] as [open],
[name] as [name] FROM snmp_trap_log
inner join machines on machines.[machine] = snmp_trap_log.[mach_id]

In hibernate my current mapping creates the equivalent of this:

SELECT [id] as [id],
[writetime] as [writetime],
[mach_id] as [mach_id],
[port_id] as [port_id],
[timeslot] as [timeslot],
[trap_oid] as [trap],
[severity] as [severity],
[message] as [message],
[source_app] as [source],
[open] as [open],
[name] as [name] FROM snmp_trap_log
inner join machines on snmp_trap_log.[id] = machines.[machine]

Hibernate version:

2.0.0.1001

Mapping documents:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Digitalk.Gateway.Core.DomainObjects.SnmpTrapLog,Digitalk.Gateway.Core" table="snmp_trap_log" lazy="true">
<id name="ID" column="id" type="int">
<generator class="native" />
</id>
<property name="Writetime" column="writetime" type="DateTime" not-null="true" />
<property name="MachId" column="mach_id" type="int" not-null="true" />
<property name="PortId" column="port_id" type="int" />
<property name="Timeslot" column="timeslot" type="byte" />
<property name="TrapOid" column="trap_oid" type="string" not-null="true" />
<property name="Severity" column="severity" type="byte" not-null="true" />
<property name="Message" column="message" type="string" not-null="true" />
<property name="SourceApp" column="source_app" type="byte" not-null="true" />
<property name="Open" column="`open`" type="Boolean" not-null="true" />
<join table="Machines" >
<key column="machine" />
<property name="MachineName" column="name" type="string"/>
</join>
</class>
</hibernate-mapping>

Name and version of the database you are using:
SQL Server 2000 - gateway

Any help would be greatly appreciated.

Paul.


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.