As far as I know, nothing like this exists. I wouldn't say that it's
trivial, but I would expect that writing something to generate it would be
relatively straightforward in design terms.

On Mon, Oct 19, 2009 at 2:17 AM, opyate <opy...@gmail.com> wrote:

>
> Hello Lifters,
>
> Related:
>
> http://groups.google.com/group/liftweb/browse_thread/thread/20051762b58f0083/b3329f33e8f3dc73?lnk=gst&q=existing+database#b3329f33e8f3dc73
>
> I would like to generate (at run-time) BaseMapper instances of a
> schema. I know I can generate the JPA beans from a schema (using
> Hibernate3 tools - thanks to Greg Meredith for pointing this out), but
> then I'd like to convert these to BaseMapper instances so I can use
> the .toForm: NodeSeq functionality. Or schema to BaseMapper directly?
> Schemifier in reverse, perhaps.
>
> Use case: I'm building an open source tool with which you can define
> external databases to manage. I wouldn't know the details of these
> databases at design/compile time, and thusly would like to be able to
> just point to a database, point to a table (related tables if foreign
> key exists), dynamically generate a form for the table/row, edit,
> save. I know this sounds really far-fetched, and fragile. I just want
> to see if it's viable :-)
>
> With javax.sql I can generate the form, hence the SQL and then call an
> insert/update on the target DB, but I'd prefer a Mapper solution.
>
> CODE-START
> Class.forName ("com.mysql.jdbc.Driver").newInstance() // could be any
> db type
> val sConnection = "jdbc:mysql://host:3306/dbname" // some DB known at
> run-time
> val conn: Connection = DriverManager.getConnection(sConnection,
> "db_user", "db_password")
> val sqlStatement: Statement = conn.createStatement()
> val rs: ResultSet = sqlStatement.executeQuery("select * from " +
> someRuntimeTable + " limit 1")
> val rsm: ResultSetMetaData = rs.getMetaData()
> // now we have a slew of methods at our disposal which tells us things
> about the table, for example:
> rsm.isAutoIncrement(1) // example
> for (i <- 1 to rsm.getColumnCount()) {
>  rsm.getColumnLabel(i) // example
>  rsm.getColumnTypeName(i) // example
> }
> CODE-END
>
> Thanks,
> Juan
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to