0

I have six tables that have many common fields.

Ten years ago I specified something to Hibernate Reverse Engineering to create a mapped superclass and six classes that extend that class.

I could do it manually, but I am sure the capability must still be there.

After two hours of googling and seeing example of hand crafted pojos, I can't find how to get reveng to do it.

1 Answers1

0

I never did figure it out. Instead I wrote an Interface and an abstract class and then modified the generated code.

Not pretty, but it actually has more benefits to me.

Strangely enough the class I extend must have a setter method for every property or the application fails to load.

I have created setters that just throw UnsupportedOperationException

Now if could just get two source trees in this project and have the target classes generated by hibernate compile without this nonsense.

apply() {
FILE=$1
echo $FILE
return
#https://stackoverflow.com/questions/11694980/using-sed-insert-a-line-below-or-above-the-pattern
#https://stackoverflow.com/questions/148451/how-to-use-sed-to-replace-only-the-first-occurrence-in-a-file
sed -i -e "0,/implements/{s/implements/extends AbstractDemand implements/}" $FILE

sed -i -e "3i  \
import com.techwanker.diamond.planning.AbstractDemand;\\n\
import com.techwanker.diamond.planning.AllocationMode;\\n\
import com.techwanker.diamond.planning.demand.DemandType;\\n\
" $FILE 
}

find_file() {
   file=`locate $1 | grep "^$PWD" | grep $1\$`
   return $file


rm -rf src/main/java
mvn hibernate3:hbm2java
apply `find_file ApsDmdOo.java`
apply `find_file ApsDmdSs.java`
apply `find_file ApsDmdFc.java`



cp -r src/main/java-required/java/* src/main/java
cp -r target/generated-sources/* src/main/java
mvn install