title: Error trying to save to Postgresql with Spring & Hibernate
body: <p>I have a spring-boot 1.2.1 application that uses spring-data-jpa, liquibase and postgresql.  I have two entities that I am trying to persist, and I am getting an error that doesnt' seem to make sense (to me at least).</p>
  
  <p>Here is my liquibase definition:</p>
  
  <pre><code>&lt;createTable tableName="ROLE"&gt;
       &lt;column name="role_id" type="bigint" autoIncrement="true"&gt;
             &lt;constraints primaryKey="true"/&gt;
       &lt;/column&gt;
        &lt;column name="role_type" type="varchar(100)"/&gt;
        &lt;column name="role_description" type="varchar(300)"/&gt;
    &lt;/createTable&gt;
  
    &lt;createTable tableName="ROLEMENU"&gt;
        &lt;column name="role_menu_id" type="bigint" autoIncrement="true"&gt;
             &lt;constraints primaryKey="true"/&gt;
         &lt;/column&gt;
         &lt;column name="role_id" type="bigint"/&gt;
         &lt;column name="display_text" type="varchar(500)"/&gt;
         &lt;column name="display_order" type="int"/&gt;
     &lt;/createTable&gt;
  </code></pre>
  
  <p>and the entities:</p>
  
  <pre><code>@Entity
  @Table(name = "ROLE")
  public class Role {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private long roleId;
  
      @Enumerated(EnumType.STRING)
      @Column(name = "roleType", nullable = false)
      private RoleType roleType;
  
      private String roleDescription;
  
      @OneToMany(cascade = CascadeType.ALL, mappedBy = "role", fetch = FetchType.EAGER)
      @Fetch(value = FetchMode.SUBSELECT)
      private List&lt;RoleMenu&gt; roleMenuList = new ArrayList&lt;RoleMenu&gt;();
  //getters and setters
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@Entity
  @Table(name = "ROLEMENU")
  public class RoleMenu {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private long roleMenuId;
  
      @OneToMany(cascade = CascadeType.ALL, mappedBy = "roleMenu", fetch = FetchType.EAGER)
      private List&lt;RoleMenuItem&gt; roleMenuItems = new ArrayList&lt;RoleMenuItem&gt;();
  
      @ManyToOne(fetch = FetchType.EAGER)
      @JoinColumn(name = "roleId")
      private Role role;
  
      private String displayText;
      private int displayOrder;
      //getters and setters
      }
  </code></pre>
  
  <p>I use a seeder to populate the database:</p>
  
  <pre><code>@Component
  public class RoleSeeder {
  @Autowired
  private RoleRepository roleRepository;
  
  public List&lt;Role&gt; seed() {
      List&lt;Role&gt; roles = new ArrayList&lt;Role&gt;();
      roles.add( RoleFactory.buildRole( RoleType.OWNER ) );
      roles.add( RoleFactory.buildRole( RoleType.VISITOR ) );
      roleRepository.save( roles );
      return roles;
  }
  </code></pre>
  
  <p>which uses this to create:</p>
  
  <pre><code>private static Role buildOwner() {
          Role owner = new Role();
          owner.setRoleDescription( OWNER_DESCRIPTION );
          owner.setRoleType( RoleType.OWNER );
          return owner;
      }
  </code></pre>
  
  <p>When the CRUDRepository tries to save I get the following exception:</p>
  
  <pre><code>2015-02-12 08:09:32.422 DEBUG 10089 --- [           main] org.hibernate.SQL                        : insert into role (role_description, role_type) values (?, ?)
  Hibernate: insert into role (role_description, role_type) values (?, ?)
  2015-02-12 08:09:32.435 DEBUG 10089 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : could not execute statement [n/a]
  
  org.postgresql.util.PSQLException: ERROR: relation "role" does not exist
    Position: 13
  </code></pre>
  
  <p>This works quite happily on H2, but I am not sure what differences PostgreSQL is expecting me to account for.  </p>
  
  <p>One thing that is concerning is that if I have my <code>spring.datasource</code> properties set, Liquibase does not get invoked.  If I comment them out, the default datasource seems to be created and then the java code executed.  here are the values I am using for my Postgresql:</p>
  
  <pre><code>spring.datasource.url=jdbc:postgresql://localhost:5432/myschema
  spring.datasource.username=user
  spring.datasource.password=password
  spring.datasource.driverClassName=org.postgresql.Driver
  spring.jpa.database=POSTGRESQL
  </code></pre>