0

A custom source code generator was used in order to create the classes necessary for the MySQL database as described in this question: How to setup username and password with Slick's source code generator?

Then tried to follow the getting started guide in order to execute the most simple queries using SLICK and try out its capabilities.

The TableQuery vals created from source code generator do not have the attribute ddl in order to execute something like that: suppliers.ddl

Also I tried to create my own having a code like that: val models = TableQuery[Model]

So I tried this: models += ModelRow(...) but this is not working because compiler complains that model is not a string and also that a re-assignment to a val is being performed.

In addition the models.foreach(....) method does not exist.

I have started on the wrong foot here. Some help is required to get on the right track. Thank you

Community
  • 1
  • 1
George Pligoropoulos
  • 2,919
  • 3
  • 33
  • 65
  • 1
    Do you have corrrect imports? The generated classes themselves don't have ddl methods, importing e.g. `import slick.driver.MySQLDriver.simple._` makes some required implicit conversions available. – Martin Kolinek Jan 26 '14 at 09:20

2 Answers2

1

Finally I figured out what needed to be done by combining several posts found in the internet

For busy developers there is a guide explaining the entire solution and how to integrate slick into play framework in a fast in this blog post: http://pligor.tumblr.com/post/75933978759/integrate-slick-2-0-into-play-the-easy-and-fast-way

Enjoy!

PS: Thanks @Martin Kolinek for the help

George Pligoropoulos
  • 2,919
  • 3
  • 33
  • 65
0

Seems like you are learning Scala and Slick at the same time. Make sure you take some time to learn Scala on its own. You need to be familiar with Scala concepts like val, etc. to make sense of Scala code. To sensibly understand compiler error messages you need to know a little more. E.g. that (like extension methods in C#) not every method in Scala actually exists inside the object it is called on. Some methods are put on from the outside using implicit conversions. But that only happens when you have the appropriate implicit conversions in scope. Otherwise the methods can simply not be found.

Try to start with this example project:

https://github.com/slick/slick-codegen-customization-example/tree/master

which is references here: http://slick.typesafe.com/doc/2.0.0/code-generation.html

cvogt
  • 11,260
  • 30
  • 46
  • Well I am using scala for some time now. So I read this link https://github.com/freekh/play-slick which has invalid doc. Then I read this link http://blog.lunatech.com/2013/08/29/play-slick-evolutions which is deprecated. Then I read this link http://www.blogeek.com.ar/2012/11/24/play-framework-2-2-1-scala-with-slick-made-easy-with-example/ which is not working because of deprecated classes. Come on I just wanted to try a simple CRUD scenario and the integration seems to take forever. Do you really believe that a decent integration should take longer than 30 minutes? – George Pligoropoulos Feb 07 '14 at 10:15
  • Sorry about the out-dated documentation in third-party blogs. Slick 2.0 is a major new release. Also starting with Slick can take some adjustment coming from other frameworks. Slick works a bit differently but also offers different and compelling features like type-safe query composition. – cvogt Feb 07 '14 at 14:27