I'm trying to use the jOOQ fetchInto()
method to map to an existing Hibernate model Organization
(class and its inheritances are below).
Organization organization = jooq().select().from(ORGANIZATION).fetchOne().into(Organization.class);
The problem I have is that I can't really understand what happens in DefaultRecordMapper as I feel I'm not entirely familiar with all the terms that are used. I'm trying to figure out how it applies to the Hibernate classes that are in my codebase.
So far what I've tried:
- Use the jOOQ generated POJO's to see if it retrieves and maps the data at all (works).
- Add a constructor, getters and setters to the
Organization
Hibernate model. - Add
@Column
annotation toname
in theOrganization
Hibernate model.
What works:
id
field gets mapped correctly.
What doesn't work:
name
field doesn't get mapped (null
).createdAt
andmodifiedAt
fields do not get mapped (null
).
My question is: Is there something I am overlooking with the mapping and what are the things I should look at concerning the classes, fields, constructors and annotations with Hibernate models? I want to eventually map all the Hibernate models in the codebase and use fetchInto
to do that.
Thanks! :)
@Entity
public class Organization extends BaseModel {
@Required public String name;
//... a lot of other code
}
@MappedSuperclass
public class BaseModel extends Model {
/** The datetime this entity was first saved. Automatically set by a JPA prePersist */
@NoBinding
@Column
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
public DateTime createdAt;
/** The datetime this entity was last modified. Automatically set by a JPA preUpdate */
@NoBinding
@Column
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
public DateTime modifiedAt;
//...
}
@MappedSuperclass
public class Model extends GenericModel { // Both Model and GenericModel are from the Play Framework
@Id
@GeneratedValue
public Long id;
public Model() {
}
public Long getId() {
return this.id;
}
public Object _key() {
return this.getId();
}
}