Announcement Announcement Module
No announcement yet.
ROO + DB2 zOS + DBRE + Vaadin + composite meaningful primary key Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • ROO + DB2 zOS + DBRE + Vaadin + composite meaningful primary key


    As you might see from the title of this post: I am in trouble ;-). Anyways: Let's get to the point!
    We have loads of so-called "Mapping" or "Configuration" tables wich all have meaningful (String) composite primary keys and NO technical key (and no chance to get one).

    I managed to solve many problems on my way, but now I am stuck.

    Here is what works so far:
    - List of entitys (with all columns visible)
    - Navigating to one entity and display it in the entity form
    - Saving the entity (only the non-primary key columns, which is ok for us)
    - deleting an entity

    The point I am lost is, that I have no Idea how I manage to get the "New" usecase working... I can modify the form, but with a lack of setters in the PK entity I cant tell the PropertyConverter where to put the data...

    Any idea? Anyone with a similar problem?

  • #2
    I don't know what is your problem. Can you provide your script, or even better the code, to see what's the matter?

    Assuming you have created your entity with the "--identifierType" attribute, in order to create a value type entity for the composite key:

    entity jpa --class ~.domain.Configuration --table T_CONFIGURATION --identifierType ~.domain.ConfigurationId --testAutomatically
    field string --fieldName value --column C_VALUE --class ~.domain.ConfigurationId 
    field string --fieldName code  --notNull --column C_CODE --class ~.domain.ConfigurationId
    The corresponding mvc...

    web mvc scaffold --class ~.web.ConfigurationController --backingType ~.domain.Configuration
    ...will create a create.jspx that allows the user to provide the "meaningful" values for the composite key:

            <field:input disableFormBinding="true" field="id.value" id="c_es_redsys_gutenberg_domain_Configuracion_id_value"  z="zT5QBOk4lRFr9+Q1pkVlhIRhVR8="/>
            <field:input disableFormBinding="true" field="id.code" id="c_es_redsys_gutenberg_domain_Configuracion_id_code" required="true" z="MY2md4IhIxCdVm/gv78ynwO2nlc="/>
    NOTE: if one of those fields is "field:textarea", the "disableFormBinding" doesn't belong to that kind of tag, and the page doesn't compile. You can manually modify the jsp page to fix that problem.

    The point is that here you can see the way to access (set or get) the meaningful values for the composite key:

    //For instance, in an integration test:
    Configuracion obj = dod.getRandomConfiguracion();
    obj.getId().setCode("new code");
    obj.getId().setValue("new value");
    NOTE: for DB2 in OS/390 with Hibernate, I have to specify the column definition attribute in the column annotation, otherwise, the queries don't work:

        @Column(name = "C_DESCRIPTION", columnDefinition = "char(250)")
        @Size(max = 250)
        private String description;
    Does it help you?