ForeignCollection - javax.persistence

37 views
Skip to first unread message

Mariák Kálmán

unread,
Apr 23, 2012, 10:57:21 AM4/23/12
to ORMLite Developers
Hi!

Does it have:

@ForeignCollectionField(eager = false)
ForeignCollection<Order> orders;

an alternative javax.persistence?

Thanks for the answer!

Gray Watson

unread,
Apr 23, 2012, 11:56:00 AM4/23/12
to ormli...@googlegroups.com
On Apr 23, 2012, at 10:57 AM, Mariák Kálmán wrote:

> @ForeignCollectionField(eager = false)
> ForeignCollection<Order> orders;

No there isn't and there should be. Is that a ManyToOne?
gray

Mariák Kálmán

unread,
Apr 24, 2012, 3:35:07 AM4/24/12
to ORMLite Developers
I tried this:
@Entity(name = "Instructors")
public class Instructor implements Serializable {

private static final long serialVersionUID = 1L;

public static final String ID_FIELD_NAME = "ID";

@Id
@Column(name = ID_FIELD_NAME)
private Long id;

@OneToMany(mappedBy = "instructor")
private List<Position> positions;
...
}

@Entity(name = "Positions")
public class Position {

public static final String ID_FIELD_NAME = "ID";

@Id
@Column(name = ID_FIELD_NAME)
Long id;

@ManyToOne
@JoinColumn(name = "ID_INSTRUCTOR")
Instructor instructor;
...
}

Usage:

List<Instructor> instructors = DaoManager.createDao(connection,
Instructor.class).queryForAll();
Is null: instructors.get(0).getPositions()

Thanks for the answer!
Reply all
Reply to author
Forward
0 new messages