Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with MappedStringIndex (Derby / H2) #13

Closed
tjweir opened this issue May 16, 2009 · 5 comments
Closed

Problems with MappedStringIndex (Derby / H2) #13

tjweir opened this issue May 16, 2009 · 5 comments

Comments

@tjweir
Copy link
Contributor

tjweir commented May 16, 2009

Problems with MappedStringIndex (Derby / H2)

Lighthouse #26: http://liftweb.lighthouseapp.com/projects/26102/tickets/26

@tjweir
Copy link
Contributor Author

tjweir commented May 16, 2009

I posted this to the mailing list back in december. Posting again so it's preserved :)

I tested this with Scala 2.7.3 and the Lift 1.0 release.
Recently I wanted to have a Mapper with a String uuid as primary key. I found out that MappedStringIndex does that. It didn't work though.

Using it with with a derby driver threw this exception:

Caused by: java.sql.SQLException: 'ID' cannot be a column of a

primary key or unique key because it can contain null values.

The create table looked here like it generated the id itself, so the lift generated id isn't saved in the db.

Using the H2 driver:
CREATE TABLE myuuidmapper (id VARCHAR(64)) INSERT INTO myuuidmapper () VALUES ()

This means the table has been created but the lift-generated id was not saved in the database.

I attached an example project. Boot.scala is configured to use the Derby driver. If requested I can provide an example for H2.

@dchenbecker
Copy link
Member

This is in progress, and dependent on issue #231 making it into trunk. We'll have to discuss whether we want to back-port some of the related code into the 1.0 line.

@dchenbecker
Copy link
Member

This works now in 1.1-SNAPSHOT by modifying the MyUuidMapper class to change:

object id extends MappedStringIndex(this, 64)

to

object id extends MappedStringIndex(this, 64) {
  override def dbNotNull_? = true
  override def dbAutogenerated_? = false
}

@github-importer
Copy link

Imported from GitHub: http://github.com/dpp/liftweb/issues/13/find

@github-importer
Copy link

Imported from Assembla: http://www.assembla.com/spaces/liftweb/tickets/13

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants