|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnl.knowledgeplaza.util.jpa.JpaReverseEngineer
public class JpaReverseEngineer
This class reverse engineers a business model (BM) from a RDBMS schema via a JDBC connection. The generated BM is not thread safe, this means only one thread-per-entity-manager is allowed to access the BM. If you have code (like swing applications) that spawn threads, make sure only one is accessing the BM at the same time using a lock or other synchronization mechanism. http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/locks/Lock.html Since it practically is impossible to write thread safe BM's (like it is to write threads safe GUI libraries, like Swing), this is left to the developer. Please be aware that when coding against another threading environment (e.g. Swing) this may result in some "interesting" logic, especially when using a binding library. For example: suppose a separate thread was spawned to do some heavy lifting in the BM. This thread will do some work, create or alter collections, and as a result some Swing components have to be updated. The Swing components most likely will directly use the BM, e.g. a List that will shown, say, Persons using a custom Renderer, or a Textfield that displays a name or total. These swing components most likely are bound to the BM using a binding library (e.g. JGoodies). Ok, suppose the worker sets the name of a person, the binding library will then automatically update the TextField. But unless the binding library hands it over to the Swing Thread, this will be done outside the Swing thread! To be continued...
| Field Summary | |
|---|---|
static String |
ATLOADTIMEPOSTFIX
|
| Constructor Summary | |
|---|---|
JpaReverseEngineer()
|
|
| Method Summary | |
|---|---|
protected String |
convertDbIdentifierToJavaNotation(String id,
String type,
boolean stripIdPostfix)
Converts database id to java id, allowing for id overriding, and incorporates stripping |
static String |
convertDbIdentifierToJavaNotationPure(String id)
Converts a database id to java id without any tuning The resulting Java camelcase ID will start with a capital |
protected String |
convertDbIdentifierToJavaProperty(String id,
String type)
Without stripping "nr" |
protected String |
convertDbIdentifierToJavaPropertyStripIdPostfix(String id,
String type)
With stripping "nr" |
void |
generateClass(File javaFile,
String packageName,
String tableName,
String className,
boolean isWritable)
|
void |
generateClass(String baseDirName,
String packageName,
String tableName,
boolean isWritable)
|
void |
generatePKClass(File lJavaFile,
String lPackageName,
String lTableName,
String lClassName,
List<String> lPrimaryKeys,
Map<String,String> primaryKeyColumnToJava)
|
protected String |
getWhereIAm()
|
void |
go()
|
static void |
main(String[] args)
|
protected String |
pullThroughConfigurationPropertiesRenameRules(String id,
String type)
See if there are rename rules for this id |
protected boolean |
skipTable(String tableName)
|
protected void |
writeComparator(Map<String,String> properties,
String packageName,
String className,
Writer lWriter)
|
protected String |
writeDefaultValue(String lJavaType,
String defaultValue)
|
protected void |
writeFindBy(Map<String,String> properties,
String packageName,
String className,
Writer lWriter,
List<String> findByMethods)
Generate additional findBy methods using unique properties |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static String ATLOADTIMEPOSTFIX
| Constructor Detail |
|---|
public JpaReverseEngineer()
properties - | Method Detail |
|---|
public static void main(String[] args)
args -
public void go()
throws SQLException
SQLException
public void generateClass(String baseDirName,
String packageName,
String tableName,
boolean isWritable)
throws SQLException
databaseMetaDataRs -
SQLException
public void generateClass(File javaFile,
String packageName,
String tableName,
String className,
boolean isWritable)
throws IOException,
SQLException
databaseMetaDataRs -
IOException
SQLException
public void generatePKClass(File lJavaFile,
String lPackageName,
String lTableName,
String lClassName,
List<String> lPrimaryKeys,
Map<String,String> primaryKeyColumnToJava)
throws IOException,
SQLException
databaseMetaDataRs -
IOException
SQLException
protected void writeFindBy(Map<String,String> properties,
String packageName,
String className,
Writer lWriter,
List<String> findByMethods)
throws IOException
properties -
IOException
protected void writeComparator(Map<String,String> properties,
String packageName,
String className,
Writer lWriter)
throws IOException
properties - packageName - className - lWriter -
IOException
protected String convertDbIdentifierToJavaPropertyStripIdPostfix(String id,
String type)
lId -
protected String convertDbIdentifierToJavaProperty(String id,
String type)
lId -
protected String convertDbIdentifierToJavaNotation(String id,
String type,
boolean stripIdPostfix)
lId -
public static String convertDbIdentifierToJavaNotationPure(String id)
id -
protected String pullThroughConfigurationPropertiesRenameRules(String id,
String type)
lId -
protected String writeDefaultValue(String lJavaType,
String defaultValue)
lColumnType -
protected String getWhereIAm()
protected boolean skipTable(String tableName)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||