Lets say i have 2 tables (mysql)
table A:
idA,name,phone

table B:
idB,data1,data2,idA

in table B: idA is used as foreign key and it is configured via mysql workbench.

now, i am trying to use Hibernate with jersy (building some kind of rest API)

and I am using netbeans as my IDE.

finally if got:

1. A.java
2. B.java
3. A.hbm.xml
4. B.hbm.xml

B.hbm.xml

```
<many-to-one name="a" class="DataTypes.A"> 
    <column name="idA" length="45" not-null="true"  />
</many-to-one>
...

```

and in B.java

```
public class B implements java.io.Serializable {

     private Integer idB;
     private A a;
     ...
}

```

A.java

```
public class User implements java.io.Serializable {

    private String idA;
    private String 
private Set<B> bs = new HashSet<B>(0);
     ....
}

```

and some part in A.hbm.xml

```
<set name="bs" inverse="true">
    <key>
        <column name="idA" length="45" not-null="true" />
    </key>
    <one-to-many class="DataTypes.B" />
</set>

```

the main problem is when i uses hibernate to get all entries of table A the result is hibernate queries for all A records and for each record it looks for it's B's (Set) after it got its B (because its foreign key) its looks again for its A and so on.. 

2 questions :) :
is there any solution for this recursion? or should i cut this circular reference?
is my database model is OK? (foreign key)

Thank you for your time.