You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I might be about to give up on Exposed and scurry back to Hibernate. I'm trying to fetch a complete object graph but without eager fetching of collections, I don't know how to do it. I'm assuming a three-layer separation of concerns - a web layer, a service layer, and a DB/DAO layer. My service layer wants to convert the DB/DAO objects (like PageTemplates below) into a viewable web layer model. Where should my transaction blocks be? In the DAO, or in the service layer?
Given this model:
object PAGE_TEMPLATE : LongIdTable() {
val refName = varchar("ref_name", 255).uniqueIndex()
}
object INPUT_FIELD : LongIdTable() {
val refName = varchar("ref_name", 255).uniqueIndex()
val pageTemplate = optReference("page_template", PAGE_TEMPLATE)
}
classInputFields(id:EntityID<Long>) : LongEntity(id) {
var refName by INPUT_FIELD.refName
var pageTemplate by PageTemplates optionalReferencedOn INPUT_FIELD.pageTemplate
companionobject:LongEntityClass<InputFields>(INPUT_FIELD)
}
classPageTemplates(id:EntityID<Long>) : LongEntity(id) {
var refName by PAGE_TEMPLATE.refName
val fields by InputFields optionalReferrersOn INPUT_FIELD.pageTemplate
companionobject:LongEntityClass<PageTemplates>(PAGE_TEMPLATE) {
funget(refName:String): PageTemplates? { .... ] }
}
I want to write the get(refName: String) function which will return an entire PageTemplate object, including all of its fields, eagerly fetched and ready to be sent up to the service layer as a detached object.
funget(refName:String): PageTemplates? {
var template:PageTemplates?=null
transaction(dbConnections.connect()) {
addLogger(StdOutSqlLogger)
// there will only be one matching PAGE_TEMPLATE to this query, but multiple rows because there are many INPUT_FIELDS belonging to the templateval result =PAGE_TEMPLATE.innerJoin(INPUT_FIELD).select {
PAGE_TEMPLATE.refName eq refName and (INPUT_FIELD.pageTemplate eq PAGE_TEMPLATE.id)
}.toList()
if (result !=null) {
template = wrapRows(result) // type mismatch error here
}
}
return template
}
Maybe I'm completely misunderstanding Exposed, but my gut feeling is that an ORM should allow me to do this. As it is, I feel as though I have to write a getPageTemplate(refName) function, a getInputFieldsForTemplate(refName) function, and and many more besides, at both the service and DAO layers. And that doesn't feel very ORM to me.
The text was updated successfully, but these errors were encountered:
I think I might be about to give up on Exposed and scurry back to Hibernate. I'm trying to fetch a complete object graph but without eager fetching of collections, I don't know how to do it. I'm assuming a three-layer separation of concerns - a web layer, a service layer, and a DB/DAO layer. My service layer wants to convert the DB/DAO objects (like
PageTemplates
below) into a viewable web layer model. Where should mytransaction
blocks be? In the DAO, or in the service layer?Given this model:
I want to write the
get(refName: String)
function which will return an entirePageTemplate
object, including all of itsfields
, eagerly fetched and ready to be sent up to the service layer as a detached object.Maybe I'm completely misunderstanding Exposed, but my gut feeling is that an ORM should allow me to do this. As it is, I feel as though I have to write a
getPageTemplate(refName)
function, agetInputFieldsForTemplate(refName)
function, and and many more besides, at both the service and DAO layers. And that doesn't feel very ORM to me.The text was updated successfully, but these errors were encountered: