Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    JPA2DataSource with DMI question

    Hi,

    I have a Data source defined as follows
    Code:
    <DataSource ID="usersDS"
            serverConstructor="com.isomorphic.jpa.JPA2DataSource"   
            beanClassName="cz.bcom.smartrise.server.persistence.hibernate.UsrUsers"
            dropExtraFields="true">
    I'd like to add business logic so I added
    Code:
    <serverObject lookupStyle="new" className="cz.bcom.smartrise.server.persistence.dmi.UsersDMI"/>
    In the class I'd like to set values before inserting and also read values after the object has been managed so I declared the method:
    Code:
    public DSResponse add(JPA2Entity record, DSRequest dsRequest) throws Exception {
      record.setActive(true); // this is ignored
      dsRequest.getCriteria().put("active", true); //this works
    
      DSResponse dsResponse = dsRequest.execute();
      JPA2Entity alreadyManagedEntity= (JPA2Entity)dsResponse.getData();
    
      System.out.println(alreadyManagedEntity.getId());
    }
    My asumptions are somehow wrong. I requested the JPA2Entity as a method parameter and I received it but all changes I made on it are ignored when executing dsRequest.execute();

    Do I need to set everything as attributes? What about related objects?
    dsRequest.getCriteria().put("job", jpa2EntityJob);

    best regards,
    Zdary

    #2
    The behavior of automatically filling in a bean is mostly intended for people who would make direct calls to their own custom ORM layers. If you're using DataSources, modify the DSRequest to cause changes to how the DSRequest is executed.

    Comment

    Working...
    X