Max Rydahl Andersen [
https://community.jboss.org/people/maxandersen] created the
discussion
"Re: Hibernate Tools question"
To view the discussion, visit:
https://community.jboss.org/message/759541#759541
--------------------------------------------------------------
Any particular reason your columns doesn't have not-null set ?
in hbm.xml you can add a "default-value" meta-attribute.
<property name="content" type="string"
length="10000">
<meta attribute="default-value"></meta>
</property>
that will make it generate:
content = ""
For reverse engineering this is trickier, but there are two options.
Create a reveng.xml file that sets <meta> for the columns you need it for.
Example of that can be found at
https://github.com/hibernate/hibernate-tools/blob/master/src/test/org/hib...
https://github.com/hibernate/hibernate-tools/blob/master/src/test/org/hib...
Mind you that reveng.xml is "additative" meaning you can just specify the column
name, everything else will come from jdbc.
If that is not enough you would need to implement a ReverseEngineeringStrategy that has a
method similar to:
public Map columnToMetaAttributes(TableIdentifier identifier, String column) {
Map result = new HashMap<String, MetaAttribute>();
MetaAttribute ma = new MetaAttribute("default-value");
String defaultValue =
logicToFigureOutValueBasedonTableColumn(identifier, column);
ma.addValue(defaultValue);
result.put("default-value", ma);
return result;
}
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/759541#759541]
Start a new discussion in JBoss Tools at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]