I have a DataNucleus project and I am using JDO to reverse map a datastore to my classes. I do this very easily with:
package com.sample;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.PrimaryKey;
@PersistenceCapable(table = "source")
public class Source {
@PrimaryKey
private String source_id;
private Topic topic_id;
private String url;
private String description;
// getters and setters
}
public class Topic {
private String topic_id;
private String topicName;
private String topicDescription;
// getters and setters
}
The topic_id
is a foreign key to another table, topic, which contains an id, a topicName, and a topicDescription.
I know that it is possible, using annotations, to return topic.id, topic.topicName, and topic.topicDescription with the topic_id. I just cannot figure out how, and I find the documentation to be a bit cryptic, especially for reverse mapping.
Can anyone lend a hand and provide an example? I've tried playing around with the @ForeignKey and @Element annotations, but I haven't had any luck yet.
Thanks!