So I, like many people, am trying to get a list of objects out of my database. I can insert them just fine. Getting them back is another issue.
When I create the database and insert the objects, everything is inserted fine. The data DOES Exist. It does not get returned. When I run a debug and inspect the object returned, the object returned is of
PersistantBag, and the Bag is of type
ArrayList and it is empty. i.e. when selected it contains a list of
[].
Any thoughts? Im pretty sure I am doing this correct...
My Hibernate CFG:
Code:
<hibernate-configuration>
<session-factory>
<!-- Connection information -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/caseTool_myExperiment</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<!-- Connection limit -->
<property name="hibernate.connection.pool_size">20</property>
<!-- Do not hang on to connections on close -->
<property name="hibernate.connection.release_mode">on_close</property>
<!-- Show SQL queries in the console -->
<property name="show_sql">true</property>
<!-- Connect to MySQL Database -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.current_session_context_class">thread</property>
<!-- Allow Create/Update to the database -->
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping class="org.niu.cs.caseTool.myExperiment.objects.Credit" />
<mapping class="org.niu.cs.caseTool.myExperiment.objects.WorkflowMetadata" />
</session-factory>
</hibernate-configuration>
Part of my class that contains a OneToMany association:
Code:
@Entity
public class WorkflowMetadata {
private List<Credit> credits;
public WorkflowMetadata(){
credits = new ArrayList<Credit>();
}
@OneToMany(targetEntity = Credit.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "credit_id")
public List<Credit> getCredits() {
return credits;
}
public void setCredits(List<Credit> credits) {
this.credits = credits;
}
}
The Credit class:
Code:
@Entity
public class Credit extends UriResourceObject{
private WorkflowMetadata wfMetadata;
@ManyToOne
@JoinColumn(name="credit_id", insertable=false, updatable=false)
public WorkflowMetadata getWfMetadata() {
return wfMetadata;
}
public void setWfMetadata(WorkflowMetadata wfMetadata) {
this.wfMetadata = wfMetadata;
}
}