Breeze / breeze.server.java

Breeze support for java servers
MIT License
15 stars 3 forks source link

Any plans to support metadata generation based on DTO? #1

Closed Dhana-Krishnasamy closed 8 years ago

Dhana-Krishnasamy commented 9 years ago

Any plans to support metadata generation based on DTOs as its done in .NET world? I dont want to tie my client code to the db.

Thanks

steveschmitt commented 9 years ago

You mean, using reflection to inspect the properties of the server-side domain model, and generate the metadata based on that? It should work for data properties, but it's hard to get the cardinality right for navigation properties.

Dhana-Krishnasamy commented 9 years ago

No. I meant something like whats explained in this doc: http://www.breezejs.com/documentation/ef-design-tool

Basically If I generate a dummy hibernate config with required relationships, the framework should provide way to may my DTOs to Entities by hand, so when SaveChanges is called I can pluck data from DTO pass it to DB Entities. Or Is it already supported and I'm missing the docs?

steveschmitt commented 8 years ago

Sorry I didn't get back to you. The server implementation has changed significantly since you asked this question. Now saves are performed using a SaveWorkState object, which has methods beforeSaveEntity, beforeSaveEntities, and beforeCommit.

Using the beforeSaveEntities method, you can intercept the save process and change your DTOs to Entities prior to save. See the SaveProcessor doc and the SaveWorkState JavaDoc for more info.