Please, help me learn !!!

I have the following situation:
  
a Customer class with a collection of enums which represent weekdays { Sun,
Mon , Tue , ... }    
( in JSF, I bind these to a UISelectMany component - checkboxes )

@Entity
public class Customer extends BaseLocation implements Serializable {
...
    private List<DaysOfWeek> distDays = new ArrayList<DaysOfWeek>();
    
    @CollectionOfElements( targetElement = DaysOfWeek.class )
    @JoinTable( name = "Customer_DistDay" )
    @Enumerated( EnumType.STRING )
    @Column(name = "distDay", nullable = false)
    public List<DaysOfWeek> getDistDays() { return distDays; }

    public void setDistDays(List<DaysOfWeek> distDays) { this.distDays =
distDays; }   
...
}

I also have a CustomerForm action which is modeled exactly like appfuse's
UserForm: 
* edit() to initialize the backBean to an existing customer if (id != null) 
or to a new customer;
* save(), which calls customer = customerDao.saveCustomer(customer) -
saveOrUpdate() with a flush();
* remove() calls remove from GenericDaoHibernate.

I have been battling a long time to get the LazyLoading working:
* First, I enabled
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter for
everything in my path: 
This got me the viewing power both in CustomerList and CustomerForm. 
Nayice!  
I can "add" a new Customer.
I can't "update"  (NonUniqueObjectException: a different object with the
same identifier value was already associated with the session ... )
I can't "delete"
(org.springframework.dao.InvalidDataAccessApiUsageException: Write
operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL) ... )

* Second, without much thinking/understanding, I extended my
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter with the
recommended flush strategy from 
http://wiki.apache.org/myfaces/Hibernate_And_MyFaces
http://wiki.apache.org/myfaces/Hibernate_And_MyFaces  (it uses
FlushMode.COMMIT):
Now I got the views, "create" and "remove" working.  SWELL

BUT "update" does not work (NonUniqueObjectException: a different object
with the same identifier value was already associated with the session ...
).

I suppose it's because the session, which contained it, no longer exists. 
So, hibernate thinks I'm being stupid, maybe I am.  

Please, help !!
-- 
View this message in context: 
http://www.nabble.com/hibernate%3A-Lazy-Loading-101-tf4316007s2369.html#a12289186
Sent from the AppFuse - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to