facebook

reverse engineering produces class without getters/setters

  1. MyEclipse Archived
  2.  > 
  3. Documentation
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #312825 Reply

    Chip Forster
    Member

    This message has not been recovered.

    #312843 Reply

    support-swapna
    Moderator

    This message has not been recovered.

    #313057 Reply

    Chip Forster
    Member

    Thanks for the response. Any clue as to why the primary key is not reported? Is there an easy solution or work-around for this? Obviously the table has an index, which should represent the primary key. I’m hoping this is NOT an issue with the JDBC driver. Or, if it is, that there is a relatively painless solution.

    #313064 Reply

    Chip Forster
    Member

    The AbstractValue Class has no fields:
    package com.myeclipse.hibernate;

    /**
    * AbstractValue entity provides the base persistence definition of the Value
    * entity. @author MyEclipse Persistence Tools
    */

    public abstract class AbstractValue implements java.io.Serializable {

    // Fields

    private ValueId id;

    // Constructors

    /** default constructor */
    public AbstractValue() {
    }

    /** full constructor */
    public AbstractValue(ValueId id) {
    this.id = id;
    }

    // Property accessors

    public ValueId getId() {
    return this.id;
    }

    public void setId(ValueId id) {
    this.id = id;
    }

    }
    I believe the lack of a primary key is the issue because if I create a table
    CREATE TABLE thiber (
    id INTEGER PRIMARY KEY,
    first_name CHAR(50),
    last_name CHAR(75) NOT NULL,
    dateofbirth DATE
    );

    Then I can reverse engineer it and the abstract class has the fields, getters and setters.

    #313067 Reply

    Chip Forster
    Member

    I also found an alternatvie call to get the primary key that does appear to work:
    Here’s the link:
    // http://opensource.atlassian.com/projects/hibernate/browse/HBX-428
    Here’s some test code and results
    System.out.println(“primary keys from thiber:”);
    DatabaseMetaData dmd = conn.getMetaData();
    rs = dmd.getPrimaryKeys(null, null, “thiber”);
    while(rs.next()){
    String columnName = rs.getString(“COLUMN_NAME”);
    System.out.println(“getPrimaryKeys(): columnName=” + columnName);
    }

    System.out.println(“primary key from value (method 1):”);
    rs = dmd.getPrimaryKeys(null, null, “value”);
    while(rs.next()){
    String columnName = rs.getString(“COLUMN_NAME”);
    System.out.println(“getPrimaryKeys(): columnName=” + columnName);
    }
    System.out.println(“primary key from value (method 2):”);
    rs = dmd.getIndexInfo(null, null, “value”, true, true);
    while(rs.next()){
    String columnName = rs.getString(“COLUMN_NAME”);
    System.out.println(“getPrimaryKeys(): columnName=” + columnName);
    }

    primary keys from thiber:
    getPrimaryKeys(): columnName=id
    primary key from value (method 1):
    primary key from value (method 2):
    getPrimaryKeys(): columnName=val_cd
    getPrimaryKeys(): columnName=val_char

    #313071 Reply

    Chip Forster
    Member

    Ok, the second method does not return the primary key, but it does return the columns upon which the index was created.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: reverse engineering produces class without getters/setters

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