- This topic has 5 replies, 2 voices, and was last updated 14 years ago by Chip Forster.
-
AuthorPosts
-
Chip ForsterMemberThis message has not been recovered.
support-swapnaModeratorThis message has not been recovered.
Chip ForsterMemberThanks 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.
Chip ForsterMemberThe 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.
Chip ForsterMemberI 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
Chip ForsterMemberOk, the second method does not return the primary key, but it does return the columns upon which the index was created.
-
AuthorPosts