Getting a Hibernate MappingException here and I can't figure out why.
Here is the error I am getting:
2014/01/13 23:58:38 [] ERROR GrailsContextLoader - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: com.apporder.User, at table: user_check_in_definition, for columns: [org.hibernate.mapping.Column(user)]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: com.apporder.User, at table: user_check_in_definition, for columns: [org.hibernate.mapping.Column(user)]
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: com.apporder.User, at table: user_check_in_definition, for columns: [org.hibernate.mapping.Column(user)]
... 4 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: com.apporder.User, at table: user_check_in_definition, for columns: [org.hibernate.mapping.Column(user)]
... 4 more
Caused by: org.hibernate.MappingException: Could not determine type for: com.apporder.User, at table: user_check_in_definition, for columns: [org.hibernate.mapping.Column(user)]
... 4 more
UserCheckInDefinition Class:
package com.xxxx
class UserCheckInDefinition {
static constraints = {
daysBetweenCheckIn(inList: [1..60])
remindDaysBefore(inList: [0,1,2,3,4,5])
startDate(nullable: true)
endDate(nullable: true)
lastCheckIn(nullable: true)
nextCheckIn(nullable: true)
checkInAlert(nullable: true)
missedCheckInEmailAlert(nullable: true)
}
static mapping = {
id generator: 'sequence', params: [sequence: 'user_check_in_definition_id_sequence']
}
User user
Boolean enabled = true
Date startDate
Date endDate
Date nextCheckIn // calculated
Date checkInAlert // calculate
Date lastCheckIn
Integer daysBetweenCheckIn = 7
Integer remindDaysBefore = 1 // actual notify days after
@Deprecated
Boolean missedCheckInEmailAlert
}
User Class:
package com.xxxx
import com.xxxx.utils.Utilities
class User implements Serializable{
transient springSecurityService
static String SERVICE_TG = "TargetGraffiti"
static String SERVICE_TG_LOCAL = "TargetGraffitiLocal"
static constraints = {
username(blank: false, unique: true)
userRealName(blank: false)
passwd(blank: false)
enabled()
phoneNumber(nullable: true)
phoneNumber2(nullable: true)
carrier(nullable: true)
description(nullable: true)
udid(nullable: true)
createdByUdid(nullable: true)
email(nullable: true)
lastReport(nullable: true)
owner(nullable: true)
webservice(nullable: true, inList: [User.SERVICE_TG, User.SERVICE_TG_LOCAL])
signature(nullable: true)
badgeNumber(nullable: true) // udid of unregistered user
trackInterval(nullable: true)
trackColor(nullable: true)
trackIconFileName(nullable: true)
type(nullable: true)
userType(nullable: true)
status(nullable: true)
punchClockStatus(nullable: true)
lastPunch(nullable: true)
lastPunchDate(nullable: true)
domainName(nullable: true)
job(nullable: true)
task(nullable: true)
app(nullable: true)
timeZone(nullable: true)
pushRegIdAndroid(nullable: true)
pushRegIdIphone(nullable: true)
dev(nullable: true)
}
static mapping = {
table 'user_' // user is a postgres reserved word
id generator: 'sequence', params: [sequence: 'user_id_sequence']
reportType cascade: 'none'
report cascade: 'none'
app cascade: 'none'
owner cascade: 'none'
reportTypes type: 'class'
}
static transients = ['pass', 'passwd2', 'facetMap', 'facetMapPlus', 'authorities', 'myRecordTypes', 'myReportTypes', 'accept']
//required
String username
String passwd
String passwd2
String userRealName
//shared
Date dateCreated = new Date()
String email
String phoneNumber // mobile number
String phoneNumber2 // office number
Carrier carrier
boolean enabled = false
boolean registered = false // citizen users are not registered, they don't know their user name and password
boolean deleted = false // virtual delete
String udid
String createdByUdid // udid of phone that created the user
Date lastReport
TimeZone timeZone // added for Zorts
Long qtyReports = 0
// todo: remove tracking fields, moved to UserTrackingDefinition
String trackInterval = "off" // in minutes
String trackIconFileName
String trackColor = "000000" // default black
Long userVersion = 0 // for syncing user data to phone
boolean saveSession = false
//citizen
boolean getReportUpdates = false
boolean getNotices = false
//web
SortedSet applications
static hasMany = [
authorities: Role,
reportTypes: ReportType,
reportTypeSticky: ReportTypeSticky
]
static belongsTo = Application
// todo: owner is a reserved field name, this should be renamed
Application owner // for belongs to one to many - users
boolean emailShow
String description = ''
// todo: clean up the user_ table, remove these columns
Application app // app currently or last logged into
// @Deprecated // replaced with owningReportPath
// Report owningReport // owner of reports for currently selected report type
// ReportType reportType // reportType currently or last chosen
// Report report // report currently or last chosen
// String facets = "" // currently selected facets as map
// String sort = "Newest" // currently select sort field
// Long listOff = 0 // pagination offset for report list
// String listMode = "list" // currently selected list view mode - list, map, photos
String webservice
Photo signature
String badgeNumber
String type
UserType userType
@Deprecated
String status
PunchClockStatus punchClockStatus
String lastPunch
Date lastPunchDate
Boolean accept // user accepted the privacy policy and terms and conditions
String domainName // domain name and port for self registered users
Boolean test = false // denotes a test user which will be deleted automatically and will not charge credit cart
// for punch clock
Report job
Report task
String pushRegIdIphone
String pushRegIdAndroid
Boolean dev = false // for iphone push notifications
// migration to new Spring Security plugin
boolean accountExpired
boolean accountLocked
boolean passwordExpired
protected void encodePassword() {
passwd = springSecurityService.encodePassword(passwd)
}
/** plain password to create a MD5 password */
String pass = '[secret]'
// self registration and subscription users
def beforeInsert() {
encodePassword()
}
def beforeUpdate() {
if (isDirty("passwd")) {
encodePassword()
}
if (username != getPersistentValue('username') ||
userRealName != getPersistentValue('userRealName') ||
description != getPersistentValue('description') ||
type != getPersistentValue('type') ||
registered != getPersistentValue('registered'))
++userVersion
}
def getAppAuthorities() {
List ret = authorities.collect { role -> role.authority }
return ret
}
String toXML() {
StringBuilder sb = new StringBuilder()
sb.append("<user id='${id}'>")
sb.append(Utilities.makeElementCdata("name", userRealName))
sb.append(Utilities.makeElement("performer", hasRole('ROLE_PERFORMER') as String)) // todo: use roles
sb.append(Utilities.makeElement("type", type))
sb.append(Utilities.makeElement("statusId", punchClockStatus?.id as String))
sb.append(Utilities.makeElement("jobId", job?.id as String))
sb.append(Utilities.makeElement("taskId", task?.id as String))
StringBuilder sb2 = new StringBuilder()
String comma = ""
for (UserRole userRole : UserRole.findAllByUser(this)) {
sb2.append(comma).append(userRole.role.authority)
comma = ","
}
sb.append(Utilities.makeElementCdata("roles", sb2.toString()))
sb.append(Utilities.makeElementCdata("filter", filter(0)))
sb.append(Utilities.makeElementCdata("filter1", filter(1)))
sb.append(Utilities.makeElementCdata("filter2", filter(2)))
sb.append("</user>")
return sb.toString()
}
String filter(int level) {
StringBuilder sb2 = new StringBuilder()
String comma = ""
if (owner?.userFilter != null) {
for (UserFilter uf : UserFilter.findAllByLevelAndUser(level, this)) {
sb2.append(comma).append(uf.report.id)
comma = ","
}
return sb2.toString()
}
return null
}
String exportXml() {
StringBuilder sb = new StringBuilder()
sb.append("<user id='${id}'>")
sb.append(Utilities.makeElementCdata("userRealName", userRealName))
sb.append(Utilities.makeElement("type", type))
sb.append(Utilities.makeElement("username", username))
sb.append(Utilities.makeElement("email", email))
sb.append(Utilities.makeElement("phoneNumber", phoneNumber))
sb.append(Utilities.makeElement("getReportUpdates", getReportUpdates))
sb.append(Utilities.makeElement("getNotices", getNotices))
sb.append(Utilities.makeElement("dateCreated", dateCreated?.toString()))
sb.append(Utilities.makeElementCdata("carrier", carrier?.name))
sb.append(Utilities.makeElement("deleted", deleted))
sb.append(Utilities.makeElement("udid", udid))
sb.append(Utilities.makeElement("createdByUdid", createdByUdid))
sb.append(Utilities.makeElement("enabled", enabled))
sb.append("<roles>")
for (UserRole userRole : UserRole.findAllByUser(this)) {
sb.append(Utilities.makeElement("role", userRole.role.authority))
}
sb.append("</roles>")
if (owner?.userFilter != null) {
sb.append("<userFilter>")
for (UserFilter uf : UserFilter.findAllByUser(this)) {
sb.append(Utilities.makeElement("id", uf.report.id))
}
sb.append("</userFilter>")
}
sb.append("</user>\r\n")
return sb.toString()
}
boolean hasRole(String role) {
return getAppAuthorities().contains(role)
}
Set<Role> getAuthorities() {
if (id == null) return []
if (userType != null)
return userType.authorities
else
return UserRole.findAllByUser(this).collect { it.role } as Set
}
String username(String server) {
String ret = username
if (server == "saveyourbooty.com" || server == "www.saveyourbooty.com") {
ret = username.replace("SYB:", "")
}
return ret
}
void decorateUsername(String server) {
if (server == "saveyourbooty.com" || server == "www.saveyourbooty.com") {
username = "SYB:${username}"
}
}
boolean hasReportType(ReportType reportType) {
boolean ret = false
for (ReportType rt : reportTypes) {
if (rt.id == reportType.id) {
ret = true
break
}
}
return ret
}
TimeZone timeZone() {
if (timeZone != null)
return timeZone
return owner.timeZone ?: TimeZone.default
}
}
I'm pretty new to Hibernate and not sure why this is causing a problem. If you need additional information please let me know. Thanks!
I figured this out. The problem was a dependency issue. I needed the postgresql extension for Grails to read the data types from a postgresql database.
This in the BuildConfig did the trick:
compile ":postgresql-extensions:0.6.1"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With