I mentioned that I would post the final code once I worked out all the
bugs, so here is what I came up with:
object SampleType extends SampleType with LongKeyedMetaMapper
[SampleType] {
override def dbTableName = "sample_type" // define the DB table name
val choices = SampleTypeList.names
def writeToTable(c: SuperConnection) (cmd: () => String) {
val makeSql = cmd()
val st = c.createStatement
st.execute(makeSql)
println(makeSql)
st.close
}
override def dbAddTable = {
DB.use(DefaultConnectionIdentifier) {
con =>
val connection = con // SuperConnection(con)
val driver = con.calcDriver
(connection.getMetaData.getDatabaseProductName)
Full(
() => {
for (i <- 1 to choices.length) writeToTable(con) {
() => "INSERT INTO "+dbTableName+" (id, name) VALUES ("+i
+", '"+choices(i-1)+"')"
}
}
)
}
}
}
Hope that helps anyone with the same problem in the future.
-David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---