following is the requirement :
We are using hibernate to persist entity objects. most of the entity
objects are of composite types
containing child entity objects or collections of child entity
objects. All these entity objects extend from an AbstractEntity class
which has following annotated field "@UpdaterId String updatedBy".
We have written a hibernate interceptor that will intercept save
method called on a session and
perform the following :
------------
// on save method from hibernate interceptor
public boolean onSave(
Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types) {
Order order = (Order)entity;
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
public void configure() {
// UpdaterIdProvider is a regular provider class that provides a
updaterid
// as a String
bind(String.class).annotatedWith(UpdaterId.class).toProvider(UpdaterIdProvider.class);
}
});
// On calling injectmembers we would like to have
cascading
// injection where the updatedby field in the child
objects (LineItem.class)
// get called
injector.injectMembers(order);
return false;
}
// end of onsave method of hibernate Interceptor
--------------------------
Order.class
public class Order{
int orderId;
@Inject @UpdaterId
String updatedBy;
@Inject
public Set<LineItem> lineItems;
public Order() {
line = new HashSet<ChildItem>();
}
public addToOrder(LineItem item) {
line.add(item);
}
}
-----------------
---------------------
Item.class
public class Item{
int itemId;
int quantity;
@Inject @UpdaterId
String updatedBy;
public Item() {
}
public void setItemId(int itemId) {
this.itemId = itemId;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
}
-------------------------------------------------
Currently the :
injector.injectMembers(order);
does not cascade injection into child lineitem objects having fields
annotated with @UpdaterId...
any thoughts on how to achieve the cascading ?
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.