MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
lforster022650
Post subject: reverse engineering produces class without getters/setters  PostPosted: Nov 19, 2010 - 06:53 PM



Joined: Nov 17, 2010
Posts: 21

package com.myeclipse.hibernate;

import javax.persistence.Entity;
import javax.persistence.Table;

/**
* Value entity. @author MyEclipse Persistence Tools
*/
@Entity
@Table(name = "value", schema = "k2user", catalog = "kinii")
public class Value extends AbstractValue implements java.io.Serializable {

// Constructors

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

/** full constructor */
public Value(ValueId id) {
super(id);
}
}
DBSCHEMA Schema Utility INFORMIX-SQL Version 7.30.UC10
Copyright (C) Informix Software, Inc., 1984-1998
Software Serial Number AAC#J814130
{ TABLE "k2user".value row size = 46 number of columns = 6 index size = 52 }
create table "k2user".value
(
val_cd char(6) not null ,
val_char char(25),
val_dec decimal(10,2),
val_dt date,
val_ind char(1),
val_int integer
);
revoke all on "k2user".value from "public";

create index "k2user".i_val_2 on "k2user".value (val_cd,val_char);

Colsole shows
2010-11-19 13:45:26,842 WARN Worker-17 org.hibernate.cfg.reveng.JDBCReader - The JDBC driver didn't report any primary key columns in value. Asking rev.eng. strategy
2010-11-19 13:45:26,842 WARN Worker-17 org.hibernate.cfg.reveng.JDBCReader - Rev.eng. strategy did not report any primary key columns for value
Not sure if this is related. Not sure what to try next.
 
 View user's profile Send private message  
Reply with quote Back to top
support-swapna
Post subject: RE: reverse engineering produces class without getters/sette  PostPosted: Nov 22, 2010 - 06:13 AM



Joined: Nov 11, 2010
Posts: 2154

lforster022650,

The getters/setters will be generated in the class AbstractValue which your Value class is extending.
You can check on this tutorial to understand on how to test it.
http://www.myeclipseide.com/documentation/quickstarts/hibernate/

Let us know how it works for you.

_________________
Swapna
MyEclipse Support
 
 View user's profile Send private message  
Reply with quote Back to top
lforster022650
Post subject: RE: reverse engineering produces class without getters/sette  PostPosted: Dec 02, 2010 - 07:11 PM



Joined: Nov 17, 2010
Posts: 21

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.
 
 View user's profile Send private message  
Reply with quote Back to top
lforster022650
Post subject: RE: reverse engineering produces class without getters/sette  PostPosted: Dec 03, 2010 - 01:25 PM



Joined: Nov 17, 2010
Posts: 21

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.
 
 View user's profile Send private message  
Reply with quote Back to top
lforster022650
Post subject: RE: reverse engineering produces class without getters/sette  PostPosted: Dec 03, 2010 - 03:28 PM



Joined: Nov 17, 2010
Posts: 21

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
 
 View user's profile Send private message  
Reply with quote Back to top
lforster022650
Post subject: RE: reverse engineering produces class without getters/sette  PostPosted: Dec 03, 2010 - 03:40 PM



Joined: Nov 17, 2010
Posts: 21

Ok, the second method does not return the primary key, but it does return the columns upon which the index was created.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits