1 Reply Latest reply on Feb 3, 2006 9:07 PM by Andy McCarty

    Hibernate is ignoring my @TABLE on select

    Victor Lewis Newbie

      I am using EJB3/Hibernate against and existing schema. I specify a table in my entity class (ROLE_TEXT, source below) but when Hibernate constructs the SQL for a query (SELECT statement below) it uses its own value for the table name, not the one I gave it.

      What have I done wrong.

      Please help!


      --------------The SELECT that Hibernate makes------------
      select roletype0_.ROLE_ID as ROLE1_16_, roletype0_.ROLE_TEXT as ROLE2_16_, roletype0_.SHORT_TEXT as SHORT3_16_ from ROLE_TEXT roletype0_

      -----------My persistance.xml file -----------

      <persistence-unit name="CalgbManager">


      ----------Entity class-----------------------------
      package org.calgb.model.roles;

      import java.io.Serializable;

      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.Id;
      import javax.persistence.Table;
      import javax.persistence.Transient;

      @Table (name="ROLE_TEXT")
      public class RoleType implements Serializable {
      private static final long serialVersionUID = 7295352269510239381L;

      protected int id;
      private String name;
      private String shortName;

      @Column (name="ROLE_ID", updatable=false )
      public int getId() {
      return id;

      public void setId(int newId) {
      id = newId;

      @Column (name="ROLE_TEXT")
      public String getName() {
      return name;

      public void setName(String name) {
      this.name = name;

      @Column (name="SHORT_TEXT")
      public String getShortName() {
      return shortName;

      public void setShortName(String shortName) {
      this.shortName = shortName;