title: SQL error when saving instance in Hibernate
body: <p>When I try save instance, I get this strange error:</p>
  
  <pre><code>WARN [15:06:27,917] JDBCExceptionReporter - SQL Error: 20000, SQLState: 42X04
  ERROR[15:06:27,917] JDBCExceptionReporter - Column 'ad0b8d24-f596-47cb-9d79-06a3c9c1de26' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'ad0b8d24-f596-47cb-9d79-06a3c9c1de26' is not a column in the target table.
  </code></pre>
  
  <p>Row is not inserted into database.
  It looks like it is trying to use scenario_id (uuid) as column name. But why?</p>
  
  <p>I am using this Data Access Object:</p>
  
  <pre><code>public interface ScenarioDao extends GenericDao&lt;Scenario, String&gt; {
      public List&lt;Scenario&gt; getScenariosWhereOwner(Person owner);
      public List&lt;Scenario&gt; getScenariosWhereOwner(Person person, int LIMIT);
  ...
  }
  
  public interface GenericDao &lt;T, PK extends Serializable&gt;{
    public PK create(T newInstance) {
      PK primaryKey = (PK) getHibernateTemplate().save(newInstance);
      return primaryKey;
  }
  }
  </code></pre>
  
  <p>POJO:</p>
  
  <pre><code>@Entity
  @Table(name = "SCENARIO")
  @XmlRootElement
  public class Scenario implements Serializable, Comparable&lt;Scenario&gt; {
  
      private static final long serialVersionUID = -6608175331606366993L;
  
      private String scenarioId;
      private Person person;
      private ResearchGroup researchGroup;
      private String title;
      private int scenarioLength;
      private boolean privateScenario;
      private String description;
      private String scenarioName;
      private String mimetype;
      private Set&lt;History&gt; histories = new HashSet&lt;History&gt;(0);
      private Set&lt;Experiment&gt; experiments = new HashSet&lt;Experiment&gt;(0);
      private boolean userMemberOfGroup;
      private Blob scenarioFile;
      private String group;
      private Boolean availableFile;
  
      private InputStream fileContentStream;
  
      @Transient
      public boolean isUserMemberOfGroup() {
          return userMemberOfGroup;
      }
  
      public void setUserMemberOfGroup(boolean userMemberOfGroup) {
          this.userMemberOfGroup = userMemberOfGroup;
      }
  
      @Transient
      public String getGroup() {
          return group;
      }
  
      public void setGroup(String group) {
          this.group = group;
      }
  
      @Transient
      public Boolean getAvailableFile() {
          return availableFile;
      }
  
      public void setAvailableFile(Boolean availableFile) {
          this.availableFile = availableFile;
      }
  
      public Scenario() {
      }
  
      public Scenario(Person person, ResearchGroup researchGroup) {
          this.person = person;
          this.researchGroup = researchGroup;
      }
  
      public Scenario(Person person, ResearchGroup researchGroup, String title,
              int scenarioLength, boolean privateScenario, String description,
              String scenarioName, String mimetype, Set&lt;History&gt; histories,
              Set&lt;Experiment&gt; experiments) {
          this.person = person;
          this.researchGroup = researchGroup;
          this.title = title;
          this.scenarioLength = scenarioLength;
          this.privateScenario = privateScenario;
          this.description = description;
          this.scenarioName = scenarioName;
          this.mimetype = mimetype;
          this.histories = histories;
          this.experiments = experiments;
      }
  
      @Id
      @GeneratedValue(generator = "system-uuid")
      @GenericGenerator(name = "system-uuid", strategy = "uuid2")
      @Column(name = "SCENARIO_ID", nullable = false, length = 36, scale = 0)
      public String getScenarioId() {
          return this.scenarioId;
      }
  
      public void setScenarioId(String scenarioId) {
          this.scenarioId = scenarioId;
      }
  
      @ManyToOne(fetch = FetchType.EAGER)
      @JoinColumn(name = "OWNER_ID", nullable = false)
      public Person getPerson() {
          return this.person;
      }
  
      public void setPerson(Person person) {
          this.person = person;
      }
  
      @ManyToOne(fetch = FetchType.EAGER)
      @JoinColumn(name = "RESEARCH_GROUP_ID", nullable = false)
      public ResearchGroup getResearchGroup() {
          return this.researchGroup;
      }
  
      public void setResearchGroup(ResearchGroup researchGroup) {
          this.researchGroup = researchGroup;
      }
  
      @Column(name = "TITLE", unique = true)
      public String getTitle() {
          return this.title;
      }
  
      public void setTitle(String title) {
          this.title = title;
      }
  
      @Column(name = "SCENARIO_LENGTH", precision = 22, scale = 0)
      public int getScenarioLength() {
          return this.scenarioLength;
      }
  
      public void setScenarioLength(int scenarioLength) {
          this.scenarioLength = scenarioLength;
      }
  
      @Column(name = "PRIVATE", precision = 1, scale = 0)
      public boolean isPrivateScenario() {
          return this.privateScenario;
      }
  
      public void setPrivateScenario(boolean privateScenario) {
          this.privateScenario = privateScenario;
      }
  
      @Lob
      @Type(type = "org.hibernate.type.TextType")
      @Column(name = "DESCRIPTION")
      public String getDescription() {
          return this.description;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      @Column(name = "SCENARIO_NAME")
      public String getScenarioName() {
          return this.scenarioName;
      }
  
      public void setScenarioName(String scenarioName) {
          this.scenarioName = scenarioName;
      }
  
      @Column(name = "MIMETYPE")
      public String getMimetype() {
          return this.mimetype;
      }
  
      public void setMimetype(String mimetype) {
          this.mimetype = mimetype;
      }
  
      @OneToMany(fetch = FetchType.LAZY, mappedBy = "scenario")
      public Set&lt;History&gt; getHistories() {
          return this.histories;
      }
  
      public void setHistories(Set&lt;History&gt; histories) {
          this.histories = histories;
      }
  
      @OneToMany(fetch = FetchType.LAZY, mappedBy = "scenario")
      public Set&lt;Experiment&gt; getExperiments() {
          return this.experiments;
      }
  
      public void setExperiments(Set&lt;Experiment&gt; experiments) {
          this.experiments = experiments;
      }
  
      @XmlJavaTypeAdapter(BlobSerializer.class)
      @Basic(fetch = FetchType.LAZY)
      @Lob
      @Column(name = "SCENARIO_FILE", nullable = true)
      public Blob getScenarioFile() {
          return this.scenarioFile;
      }
  
      public void setScenarioFile(Blob scenarioFile) {
          this.scenarioFile = scenarioFile;
      }
  
      @Override
      public int compareTo(Scenario scen) {
          return this.title.compareTo(scen.getTitle());
      }
  
      public void setFileContentStream(InputStream inputStream) {
          this.fileContentStream = inputStream;
      }
  
      @Transient
      public InputStream getFileContentStream() {
          return fileContentStream;
      }
  }
  </code></pre>
  
  <p>I try to create it using this code:</p>
  
  <pre><code> scenario = new Scenario();
              scenario.setPrivateScenario(some boolean);
              scenario.setScenarioLength(some int);
              scenario.setDescription(some string);
              scenario.setTitle(some string);
              scenario.setResearchGroup(some ResearchGroup);
              scenario.setPerson(some Person);
  </code></pre>
  
  <p>All these parameters are set correctly. I am also using GenericDao with other objects without errors. Here is insert statement generated by hibernate:</p>
  
  <pre><code>DEBUG[16:07:25,132] SQL - insert into SCENARIO (DESCRIPTION, MIMETYPE, OWNER_ID, PRIVATE, RESEARCH_GROUP_ID, SCENARIO_FILE, SCENARIO_LENGTH, SCENARIO_NAME, TITLE, SCENARIO_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
  TRACE[16:07:25,153] BasicBinder - binding parameter [1] as [LONGVARCHAR] - newscenariodescription
  TRACE[16:07:25,153] BasicBinder - binding parameter [2] as [VARCHAR] - &lt;null&gt;
  TRACE[16:07:25,153] BasicBinder - binding parameter [3] as [VARCHAR] - 9e87924e-3a14-4f82-ad57-c191ead873b5
  TRACE[16:07:25,153] BasicBinder - binding parameter [4] as [BIT] - false
  TRACE[16:07:25,154] BasicBinder - binding parameter [5] as [VARCHAR] - b399f04f-92a7-427c-9af5-f90055cb1ddc
  TRACE[16:07:25,154] BasicBinder - binding parameter [6] as [BLOB] - &lt;null&gt;
  TRACE[16:07:25,154] BasicBinder - binding parameter [7] as [INTEGER] - 5
  TRACE[16:07:25,154] BasicBinder - binding parameter [8] as [VARCHAR] - &lt;null&gt;
  TRACE[16:07:25,154] BasicBinder - binding parameter [9] as [VARCHAR] - newscenario
  TRACE[16:07:25,154] BasicBinder - binding parameter [10] as [VARCHAR] - 2d71bcd2-756e-4ffd-82b0-9649d7f05e0b
  WARN [16:07:25,180] JDBCExceptionReporter - SQL Error: 20000, SQLState: 38000
  ERROR[16:07:25,180] JDBCExceptionReporter - The exception 'java.sql.SQLException: Column '2d71bcd2-756e-4ffd-82b0-9649d7f05e0b' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then '2d71bcd2-756e-4ffd-82b0-9649d7f05e0b' is not a column in the target table.' was thrown while evaluating an expression.
  </code></pre>
  
  <p>When I try execute:</p>
  
  <pre><code>String query = "insert into SCENARIO (DESCRIPTION, MIMETYPE, OWNER_ID, PRIVATE, RESEARCH_GROUP_ID, FILE_CONTENT, SCENARIO_LENGTH, SCENARIO_NAME, TITLE, SCENARIO_ID) values ('newscenariodescription', NULL, '9e87924e-3a14-4f82-ad57-c191ead873b5', 0, 'b399f04f-92a7-427c-9af5-f90055cb1ddc', NULL, 5, NULL, 'text', '2d71bcd2-756e-4ffd-82b0-9649d7f205e0b')";
  
  session.createSQLQuery(query).executeUpdate();
  </code></pre>
  
  <p>I get same error.</p>
  
  <p>When I try execute query directly I get very strange error:</p>
  
  <pre><code>SQL Error [20000] [38000]: The exception 'java.lang.NoClassDefFoundError: org/jumpmind/symmetric/db/derby/DerbyFunctions' was thrown while evaluating an expression.
  SQL Error [XJ001]: Java exception: 'org/jumpmind/symmetric/db/derby/DerbyFunctions: java.lang.NoClassDefFoundError'.
    The exception 'java.lang.NoClassDefFoundError: org/jumpmind/symmetric/db/derby/DerbyFunctions' was thrown while evaluating an expression.
      The exception 'java.lang.NoClassDefFoundError: org/jumpmind/symmetric/db/derby/DerbyFunctions' was thrown while evaluating an expression.
        Java exception: 'org/jumpmind/symmetric/db/derby/DerbyFunctions: java.lang.NoClassDefFoundError'.
          org/jumpmind/symmetric/db/derby/DerbyFunctions
  </code></pre>