Your member variable is using the class org.joda.time.DateTime
instead of java.util.Date
By default, Hibernate does not allow for SQL statements that span multiple lines.
To allow for this, add the following line to src/main/resources/hibernate.properties
:
hibernate.hbm2ddl.import_files_sql_extractor=org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor
Use the ElementCollection
annotation and set the fetch
attribute to FetchType.EAGER
in order to eagerly load a user's nick names when loading just the user:
@Entity
public class User {
@ElementCollection(fetch = FetchType.EAGER)
private List<String> nicknames = new ArrayList<>();
Then in your import.sql
you can insert into user_nickname
:
INSERT INTO user(id, name) VALUES (1, 'Nicholas');
INSERT INTO user_nicknames (user_id, nicknames)
VALUES
(1, 'Nick'),
(1, 'Nickster');