-->
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: many to many without setters/getters
PostPosted: Tue Jan 20, 2004 2:06 pm 
Beginner
Beginner

Joined: Fri Nov 28, 2003 11:21 am
Posts: 49
Location: Buenos Aires, Argentina
Hello:

I have the following many to many relationship:
Product_type - oganization.
Where a organization may have several product types ,a product type may have several organizations (many to many).

The problem is the following the organization class dont have a product_type setter/getter ,neither product_type has organization setter/getters ,but i must retrieve from a organization all the product types linked.
I think that i must use a find ,or use HSQL,but i dont know if its possible without setter/getter.

Tables:

product_type --- product_typeOrganization --- Organization
product_id --- product_id organization_id --- organization_id

Any suggestion?.

Do i MUST include setters/getters to use hibernate?.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 20, 2004 3:13 pm 
Beginner
Beginner

Joined: Fri Nov 28, 2003 11:21 am
Posts: 49
Location: Buenos Aires, Argentina
ok,i exagerated a bit.
Product_type has a setter/getter List Organization.
Could i do something like this.

tipoproductos = GuiSGP.session.find("from TipoProducto where F_IdOrganizacion =" + idOrganizacion);

Where F_IdOrganizacion is a field of the collection table.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 9:32 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
show the mapping it's easier.
Code:
select product from Product product join Organisation organisation where organisation.myProperty= :value

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 11:39 am 
Beginner
Beginner

Joined: Fri Nov 28, 2003 11:21 am
Posts: 49
Location: Buenos Aires, Argentina
Thanks emmanuel,I tried this ,but the following exception was thrown.

net.sf.hibernate.QueryException: outer or full join must be followed by path expression [select tipoproducto from Productos.TipoProducto tipoproducto join Organizacion organizacion where organizacion.idOrganizacion=1]
t net.sf.hibernate.hql.FromParser.token(FromParser.java:166)

mappings:

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

<hibernate-mapping>
<class name="Productos.TipoProductoOrganizacion" table="T_TipoProductoOrganizacion">
<id name="idTipoProductoOrganizacion" column="P_IdTipoProductoOrganizacion" type="int">
<generator class="identity"/>
</id>
<many-to-one name="organizacion" class="Common.Organizacion" column="F_IdOrganizacion"/>
<many-to-one name="tipoProducto" class="Productos.TipoProducto" column="F_TipoProducto"/>
</class>
</hibernate-mapping>


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="Common.Organizacion" table="T_Organizacion">
<id name="idOrganizacion" column="P_IdOrganizacion" type="int">
<generator class="identity"/>
</id>
<property name="nombre" column="A_RazonSocial" type="string" />
<property name="predeterminada" column="A_Predeterminada" type="boolean" />
<property name="bajaLogica" column="A_BajaLogica" type="boolean" />
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2004 12:33 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
My fault.
Code:
select product from Product product join product.organisationList organisation where organisation.myProperty= :value

_________________
Emmanuel


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.