Hello everybody,
I'm a verry new one into the hibernate world.
Having 2 tables(A 0<-- n B) like this:
Code:
create table A (IDA int not null, primary key (IDA));
create table B (IDB int not null, IDA int, primary key (IDB));
alter table B add index FK_A_B (IDA), add constraint FK_A_B foreign key (IDA) references A (IDA);
with this mapping(gived by a MyEclipse -- Hibernate Reverse Engeenering):
Code:
[u][b]A.hbm.xml[/b][/u]
<hibernate-mapping>
<class name="db.orm.A" table="a" catalog="modaweb">
<id name="ida" type="java.lang.Integer">
<column name="IDA" />
<generator class="assigned" />
</id>
<set name="bs" inverse="true">
<key>
<column name="IDA" />
</key>
<one-to-many class="db.orm.B" />
</set>
</class>
</hibernate-mapping>
[u][b]B.hbm.xml[/b][/u]
<hibernate-mapping>
<class name="db.orm.B" table="b" catalog="modaweb">
<id name="idb" type="java.lang.Integer">
<column name="IDB" />
<generator class="assigned" />
</id>
<many-to-one name="a" class="db.orm.A" fetch="select">
<column name="IDA" />
</many-to-one>
</class>
</hibernate-mapping>
My problem is to create a method for solving this query:
select * from A,B where A.IDA=B.IDA and B.IDA=1
actually I need a method findBByForeignAID (int IDA).
Could someone give my an example for solving this problem.
Thx in advance
PS
Sorry again for my verry first experience with Hibernate.