[jboss-user] [JBoss Tools] - Hibernate Tools question

Alex Popa-Tesileanu do-not-reply at jboss.com
Fri Sep 7 06:10:42 EDT 2012


Alex Popa-Tesileanu [https://community.jboss.org/people/alexpote] created the discussion

"Hibernate Tools question"

To view the discussion, visit: https://community.jboss.org/message/758522#758522

--------------------------------------------------------------
Hi,
I tried to use reverse engineering to generate domain objects from database schema.
Everything appear to be ok.
When I tried to insert a record in the table I find it is a problem. Because all fields in the table are defined not null and have default values. The problem is hibernate try to insert all fields whether I completed only a few. Because not all fields are initialised with default values hibernate put null in the fields not initialised. This result in error on insert operation. I resolved this issue by setting values to properties in generated POJO's. 
The idea is I have hundreds of tables and I don't want to manually set default values for properties.
 
I have a question:
It is possible to set somehow reverse engineering to generate properties with default values taken from table definition?
Ex.
+public class AaaProduse implements java.io.Serializable {+
 
 
+  private String codProd;+
+  private String denProd="";+
+  private String sirGrupare="";+
+  private String sirCautare="";+
+  private BigDecimal stoc=0;+
+..............+
+instead of:+
++ 
+public class AaaProduse implements java.io.Serializable {+
 
 
+  private String codProd;+
+  private String denProd;+
+  private String sirGrupare;+
+  private String sirCautare;+
+  private BigDecimal stoc;+
 
Thank you very much,
Alex
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/758522#758522]

Start a new discussion in JBoss Tools at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2128]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120907/15ff8615/attachment.html 


More information about the jboss-user mailing list