Reputation: 21
Is there a way to change specify a "ORGANIZE BY ROW" argument when defining a table with JPA? The code I'm working on is
@Entity
@Table(name = "ANSWERS")
public class AnswerEntity {
@Id
@Column(name = "CLASS")
private String answerClass;
@Lob
@Column(name = "TEXT", unique = false, nullable = false)
private String answerText;
}
I'd like to add an "ORGANIZE BY ROW" equivalent to
CREATE TABLE ANSWERS ( CLASS VARCHAR(256), TEXT CLOB(1000000) NOT NULL ) ORGANIZE BY ROW;
Upvotes: 2
Views: 753
Reputation: 23246
Looks like you could subclass the org.apache.openjpa.jdbc.sql.DB2Dictionary and override:
getCreateTableSQL
public String[] getCreateTableSQL(Table table) Return a series of SQL statements to create the given table, complete with columns. Indexes and constraints will be created separately.
public class CutomDB2Dictionary extends DB2Dictionary{
@Override
public String getCreateTableSQL(Table table){
String sql = super.getCreateTableSQL(table);
if(table.getName().equalsIgnoreCase("ANSWERS")){
sql += " ORGANIZE BY ROW";
}
return sql;
}
}
Specify your custom DB2 dictionary in the config:
<property name="openjpa.jdbc.DBDictionary" value="com.test.CutomDB2Dictionary "/>
Upvotes: 1