Hi,
Is that possible to create method with nonpersistable field.
public interface A extends Entity { public void setB(String B); public String getB(); public String doSth(); }
I want to for example, method doSth do additional operations like duplication of B object
You could use implementation classes as described in Implementing the Active Record Pattern to do additional operations like:
@Implementation(CompanyImpl.class) public interface Company extends Entity { // ... } public class CompanyImpl { private Company company; public CompanyImpl(Company company) { this.company = company; } public void setName(String name) { company.setName(name); name = name.trim(); if (name.length() > 4) { company.setTickerSymbol(name.substring(0, 4).toUpperCase()); } else { company.setTickerSymbol(name.toUpperCase()); } } }
Hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.