facebook

Working with no pk tables using Hiberante.

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #285126 Reply

    venkat
    Member

    Hi,

    Using Hibernate reverse engineering created cfg.xml, hbm.xml and DAO supporting classes when i run the project using Maven build i am getting the size of the list but the values are null. This table doesn’t have primary key

    
    <hibernate-mapping>
        <class name="com.XXXX.history.persistence.NameXref" table="NAME_XREF" schema="UAT">
            <composite-id name="id" class="com.XXXX.history.persistence.NameXrefId">
                <key-property name="t91EntityKey" type="java.lang.String">
                    <column name="T91_ENTITY_KEY" length="25" />
                </key-property>
                <key-property name="a06Edition" type="java.lang.Long">
                    <column name="A06_EDITION" precision="2" scale="0" />
                </key-property>
                <key-property name="t91EntityKeytype" type="java.lang.String">
                    <column name="T91_ENTITY_KEYTYPE" length="1" />
                </key-property>
                <key-property name="b25Nametype" type="java.lang.String">
                    <column name="B25_NAMETYPE" length="2" />
                </key-property>
                <key-property name="e04Orignum" type="java.lang.String">
                    <column name="E04_ORIGNUM" length="25" />
                </key-property>
                <key-property name="a08Fdate" type="java.util.Date">
                    <column name="A08_FDATE" length="7" />
                </key-property>
                <key-property name="a09Xdate" type="java.util.Date">
                    <column name="A09_XDATE" length="7" />
                </key-property>
                <key-property name="b79Unit" type="java.lang.Long">
                    <column name="B79_UNIT" precision="4" scale="0" />
                </key-property>
                <key-property name="f67Special1" type="java.lang.String">
                    <column name="F67_SPECIAL1" length="20" />
                </key-property>
                <key-property name="f67Special2" type="java.lang.String">
                    <column name="F67_SPECIAL2" length="20" />
                </key-property>
                <key-property name="b94Location" type="java.lang.Long">
                    <column name="B94_LOCATION" precision="4" scale="0" />
                </key-property>
            </composite-id>
        </class>
    
    
    <hibernate-configuration>
    
        <session-factory>
            <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
            <property name="connection.url">jdbc:oracle:thin:@VICTORY-UAT:1521:uat</property>
            <property name="connection.username">inquiry</property>
            <property name="connection.password">readonly</property>
            <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
            <property name="myeclipse.connection.profile">Oracle</property>
            <property name="use_sql_comments">true</property>
            <property name="show_sql">true</property>
            <mapping resource="/hibernate_mapping/NameXref.hbm.xml" />
        </session-factory>
    
    </hibernate-configuration>
    
    public List findByProperty(String propertyName, Object value) {
            log.debug("finding NameXref instance with property: " + propertyName
                    + ", value: " + value);
            //String qString = "select * from NAME_XREF where E04_ORIGNUM = '"+value+"'";
            try {
                String queryString = "from NameXref as model where model."
                        + propertyName + "= ?";
                Query queryObject = getSession().createSQLQuery(queryString);
                queryObject.setParameter(0, value);
                //queryObject.addEntity("name", NameXref.class);
                return queryObject.list();
            } catch (RuntimeException re) {
                log.error("find by property name failed", re);
                throw re;
            }
        }

    POM

    
    <?xml version="1.0" encoding="UTF-8"?><project>
      <modelVersion>4.0.0</modelVersion>
      <groupId>com</groupId>
      <artifactId>history</artifactId>
      <packaging>war</packaging>
      <nameHistory</name>
      <version>1.0</version>
      <build>
        <plugins>
          <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>6.1.7</version>
            <dependencies>
              <dependency>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-servlet_2.4_spec</artifactId>
                <version>1.1.1</version>
                <scope>provided</scope>
              </dependency>
            </dependencies>
            <configuration>
              <scanIntervalSeconds>3</scanIntervalSeconds>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <skip>true</skip>
              <useFile>false</useFile>
            </configuration>
          </plugin>
        </plugins>
      </build>
      <dependencies>
        <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>jsp-api</artifactId>
          <version>2.0</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>servlet-api</artifactId>
          <version>2.4</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-mock</artifactId>
          <version>2.0.5</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-core</artifactId>
          <version>1.2.5</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.struts</groupId>
          <artifactId>struts2-core</artifactId>
          <version>2.0.9</version>
        </dependency>
        <dependency>
          <groupId>org.mortbay.jetty</groupId>
          <artifactId>jetty-naming</artifactId>
          <version>6.1.5</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.mortbay.jetty</groupId>
          <artifactId>jetty-util</artifactId>
          <version>6.1.5</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.mortbay.jetty</groupId>
          <artifactId>jetty</artifactId>
          <version>6.1.5</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.mortbay.jetty</groupId>
          <artifactId>jetty-plus</artifactId>
          <version>6.1.5</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate</artifactId>
          <version>3.2.5.ga</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>dom4j</groupId>
          <artifactId>dom4j</artifactId>
          <version>1.6.1</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>xml-apis</groupId>
          <artifactId>xml-apis</artifactId>
          <version>1.3.04</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>oracle</groupId>
          <artifactId>oracle.jdbc</artifactId>
          <version>9.2.0.5</version>
          <scope>system</scope>
          <systemPath>${basedir}\src\main\webapp\WEB-INF\lib\ojdbc14.jar</systemPath>
        </dependency>
        <dependency>
          <groupId>org.hibernate</groupId>
          <artifactId>hibernate-entitymanager</artifactId> 
          <version>3.2.0.ga</version>
        </dependency>
        <dependency>
          <groupId>javax.persistence</groupId>
          <artifactId>persistence-api</artifactId> 
          <version>1.0</version>
        </dependency>
        <dependency>
          <groupId>antlr</groupId>
          <artifactId>antlr</artifactId> 
          <version>2.7.6</version>
        </dependency>
      </dependencies>
    </project>
    

    Pl give me any solution for this

    Thanks
    Venkuk
    🙂

    #285176 Reply

    Loyal Water
    Member

    Did you generate the hibernate using MyEclipse ?

    Can you go to MyEclipse > Installation Summary > Installation Details and paste the information here for me.

    #285199 Reply

    venkat
    Member

    This message has not been recovered.

    #285200 Reply

    venkat
    Member

    This message has not been recovered.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Working with no pk tables using Hiberante.

You must be logged in to post in the forum log in