Search code examples
hibernateslickvalue-type

How can I implement Value Types in Slick?


In Hibernate working with Value Types is something similar to this:

Having a Table User (Name, Surname, Address), if I want Address to have more fields but not to be an Entity, Hibernate allows me to create an embeddable class like this:

@Embeddable
public class Address{
    private String street;
    private String city;
    ...
}

And a user class representing the table with an attribute Address:

@Entity
@Table (name="USER")
public class User{
    private String name;
    private String surname;
    private Address address;
    ...
}

At the end, the Table User have for fields (Name, Surname, Street, City) but those two fields are managed throw the class Address.

I know there are differences between Slick and Hibernate but this seems to me something very basic to not been supported in Slick so, is there any way to do the same with Slick?


Solution

  • You wouldn't do that in Slick. Here is what you would do instead:

    http://slick.typesafe.com/doc/2.1.0/orm-to-slick.html#navigating-the-object-graph