Hi All!
I'm having problems with ordering a select result with a joined-subclass. I looked for the way to do this, but I didn't found.
The tables:
Code:
CREATE TABLE agente
(
agecod serial NOT NULL,
agenom varchar(100),
ageobs varchar(70),
CONSTRAINT agente_pkey PRIMARY KEY (agecod)
)
WITHOUT OIDS;
ALTER TABLE agente OWNER TO postgres;
Code:
CREATE TABLE empresa
(
empage int4 NOT NULL,
empfran int4 NOT NULL,
empcnpj varchar(14),
empie varchar(8),
empim varchar(8),
empfuso int2,
CONSTRAINT empresa_pkey PRIMARY KEY (empage),
CONSTRAINT empresa_empage_fkey FOREIGN KEY (empage)
REFERENCES agente (agecod) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT empresa_empfran_fkey FOREIGN KEY (empfran)
REFERENCES franquia (franage) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITHOUT OIDS;
ALTER TABLE empresa OWNER TO postgres;
The Map:Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="br.com.trimbase.rastreio.Agente" table="agente">
<id name="cod" column="agecod" type="integer">
<generator class="native">
<param name="sequence">agente_agecod_seq</param>
</generator>
</id>
<property name="nome" column="agenom" />
<property name="obs" column="ageobs"/>
<set name="enderecos" table="endereco">
<key column="endage" not-null="false"/>
<one-to-many class="br.com.trimbase.rastreio.Endereco"/>
</set>
<set name="comunicacoes" table="comunicacao">
<key column="comage" not-null="false"/>
<one-to-many class="br.com.trimbase.rastreio.Comunicacao"/>
</set>
<joined-subclass name="br.com.trimbase.rastreio.ClientePF" extends="br.com.trimbase.rastreio.Agente"
table="clientepf">
<key column="cliage"/>
<property name="rg" column="clirg"/>
<property name="cpf" column="clicpf"/>
</joined-subclass>
<joined-subclass name="br.com.trimbase.rastreio.Motorista" extends="br.com.trimbase.rastreio.Agente"
table="motorista">
<key column="motage"/>
<property name="celular" column="motcel"/>
<property name="senha" column="motsen"/>
<property name="senhaRoubo" column="motsenroubo"/>
</joined-subclass>
<joined-subclass name="br.com.trimbase.rastreio.Empresa" extends="br.com.trimbase.rastreio.Agente"
table="empresa">
<key column="empage"/>
<property name="codFranquia" column="empfran"/>
<property name="fuso" column="empfuso"/>
<property name="cnpj" column="empcnpj"/>
<property name="ie" column="empie"/>
<property name="im" column="empim"/>
<set name="contatos" table="contato" cascade="save-update">
<key column="conemp" not-null="false"/>
<one-to-many class="br.com.trimbase.rastreio.Contato"/>
</set>
<set name="veiculos" table="veiculo">
<key column="veiageemp" not-null="false"/>
<one-to-many class="br.com.trimbase.rastreio.Veiculo"/>
</set>
<set name="pontos" table="pontodeinteresse">
<key column="ponintemp" not-null="false"/>
<one-to-many class="br.com.trimbase.rastreio.PontoDeInteresse"/>
</set>
</joined-subclass>
<joined-subclass name="br.com.trimbase.rastreio.Usuario" extends="br.com.trimbase.rastreio.Agente"
table="usuario">
<key column="usuage"/>
<property name="nivel" column="usuniv"/>
<property name="login" column="usuusu"/>
<property name="senha" column="ususen"/>
</joined-subclass>
<joined-subclass name="br.com.trimbase.rastreio.Franquia" extends="br.com.trimbase.rastreio.Agente"
table="franquia">
<key column="franage"/>
<one-to-one name="cobranca" class="br.com.trimbase.rastreio.Cobranca"/>
<set name="empresas" table="empresa" order-by="agenom desc">
<key column="empfran" not-null="false"/>
<one-to-many class="br.com.trimbase.rastreio.Empresa"/>
</set>
</joined-subclass>
</class>
</hibernate-mapping>
The error from hibernate:
SEVERE: ERROR: column empresas0_.agenom does not exist
I really thanks any help!!
Best Regards