This content has been marked as final.
Show 3 replies
-
1. Re: Seamgen reverse engineer, too many xml?
philip142au.philip_andrew.hotmail.com Mar 26, 2009 2:42 AM (in response to philip142au.philip_andrew.hotmail.com)Sorry that didn't format correctly.
<table name="ticket" catalog="artawardscheme">
<meta attribute="extra-import">javax.persistence.*</meta>
<meta attribute="class-code">
@PrePersist
public void onCreate()
{
created = new Date();
updated = new Date();
}
@PreUpdate
public void onUpdate()
{
updated = new Date();
}
</meta>
</table>
<table name="user" catalog="artawardscheme">
<meta attribute="extra-import">javax.persistence.*</meta>
<meta attribute="class-code">
@PrePersist
public void onCreate()
{
created = new Date();
updated = new Date();
}
@PreUpdate
public void onUpdate()
{
updated = new Date();
}
</meta>
</table> -
2. Re: Seamgen reverse engineer, too many xml?
swd847 Mar 26, 2009 2:54 AM (in response to philip142au.philip_andrew.hotmail.com)Use a generic entityListener for all your classes, configured through orm.xml
orm.xml
<?xml version="1.0" encoding="UTF-8"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd" version="1.0" > <persistence-unit-metadata> <persistence-unit-defaults> <entity-listeners> <entity-listener class="com.mypackage.EntityListener"> <pre-persist method-name="prePersist"/> <pre-update method-name="preUpdate"/> </entity-listener> </entity-listeners> </persistence-unit-defaults> </persistence-unit-metadata> </entity-mappings>
not sure about the order, pre-update may need to be first.
The entity is passed to the entityListener method as an argument, so you can set the values there.
-
3. Re: Seamgen reverse engineer, too many xml?
swd847 Mar 26, 2009 2:56 AM (in response to philip142au.philip_andrew.hotmail.com)Also it is possible to hack up the templates that seam gen uses, but that requires a bit more effort.