Config Interface how to save instance of entity in Database

Please someone can help to show an example regarding how to use Config interface to save instance or property value of an entity and also if possible in Application Properties can select the entity instance from dropdown, pickupfield, etc.

@Source(type = SourceType.DATABASE)
public interface BSConfig extends Config {

   // @Default("1")
    public Currency getDefaultCurrency();

    public void setDefaultCurrency(Currency value);

So I need save the default currency to use if user not select it in order screen.


The config interfaces mechanism is not designed to save entities. It only saves “stringified” references to entities, like sales_Currency-7efdaa07-0844-749c-6b43-a1b3a8b2b803.

So your setDefaultCurrency() method just takes your entity, creates a string reference from it and saves this reference to the app properties storage (the database in your case).

In order to edit and save the entity referenced from the app property, use regular screens and/or DataManager.

Ok thank, I use another workaround I add new boolean field to Currency entity (isDefault) so if user coche it it will be the default currency the the issue need send one request to database to get this currency