Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow (optional) update expression in @Property #94

Open
adrianshum opened this issue Oct 30, 2013 · 2 comments
Open

Allow (optional) update expression in @Property #94

adrianshum opened this issue Oct 30, 2013 · 2 comments

Comments

@adrianshum
Copy link

It is somehow related to the Lookup-on-update example.

In case I am using a DTO to get the summary from a model, and also want to use the same DTO to contribute (update) back to the model, current translation is not working:

public class Foo {
  private Bar bar;
}
public class Bar {
  private String code;
}

public FooDto {
  private String bar;
}

I would want to use expression bar.code in translating to FooDto, and do something like barDao.findByCode(this.bar) when updating Foo by FooDto. It is not possible in current Moo.

I believe in most case having only the translation expression and use it in update should be sufficient, e.g. in above case, I can simply treat the update action to be aFoo.bar.code = this.bar, while in case that the update and translation is not the same, we can have the optional update expression to deal with it.

@geoffreywiseman
Copy link
Owner

Maybe I'm missing something here. Couldn't you have something like:

public class Foo {
  @Property(translation="barDao.findByCode(bar)")
  private Bar bar;
}

public class FooDto {
  @Property(translation="bar.code")
  private String bar;
}

That seems like it would do what you're looking for.

@adrianshum
Copy link
Author

I can, but it ruin the beauty of Moo being non-instrusive, for which I put DTO related configs with my DTOs, without touching the entity itself.

And this approach also makes us harder to have different DTOs (because of, for example, different business functions) to work with same entity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants