Thanks for your answers.
One of the goal i wanted, that i didn't describe in my previous post is that i want to keep it simple and clean. To change the byte code could be an option, but the thing I liked of Hibernate is that it doesnt need any build time processing.
Following the "LightWeight class", if adding theses 5 or 7 new properties to all my classes means that I need to duplicate the xml mapping (and therefore the Spring mapping...) this might not be an option for me. I prefer to get rid of theses fields for all my classes... even if this has some effect on the vision of the whole project.
Because, following the "LightWeigh exemple", it would means to me that there is a need to create a set of 2 classes for each element of complexity plus a extended xml Schema...
Code:
public myClass;
public myClass_withPropertiesExtension;
public myClass2;
public myClass2_withPropertiesExtension;
public myClass3;
public myClass3_withPropertiesExtension;
If I understood the proxy practice correctly (probably not), the way I see it at first glance was that i could mapped a extended class on a table and tell Hibernate in the mapping that the "proxy" would be an Interface (there I can build an Interface for each Pojo, No problem here) containing only the needed fields for the first SQL.
Here the way I see it was that all my Pojo would extends a single class:
Code:
public myClass extends PropertiesExtension;
public myClass2 extends PropertiesExtension;
public myClass3 extends PropertiesExtension;
protected abstract PropertiesExtension;
MyClass, myClass2 and myClass3 extends an PropertiesExtension where the non-wanted element ares.
Code:
public class myClass extends PropertiesExtensionimplements java.io.Serializable {
// Fields
String id
String name;
String description;
// add here getters + setters
}
public class myClass2 extends PropertiesExtension implements java.io.Serializable {
// Fields
String id
String otherField;
String otherField2;
String descriptionENG;
// add here getters + setters
}
For my ExtendedElements classes, where the no-wanted element are, I dont want to get this class along, so it is abstract.
Code:
public abstract class PropertiesExtension{
private java.lang.String lastMaintUser;
private java.lang.String lastMaintType;
private java.lang.String lastMaintJob;
private int lastMaintTime;
private int lastMaintDate;
// add here getters + setters
And this is the part of xml mapping I guess i could work (but not in my tests) :
Code:
<class name="com.myClass"
table="myClassTable"
proxy="com.myClass"> <-- I could put an identical Interface here of myClass, I dont mind!
etc, etc, ...
</class>
<class name="com.myClass2"
table="myClassTable2"
proxy="com.myClass2"> <-- I could put an identical Interface here of myClass2...
I hope this is not science fiction...
Thanks!