SourceForge has been redesigned. Learn more.

Virtual Entity backed from NamedQuery

  • webfrank

    webfrank - 2013-09-24

    I would like to achive a simple dropdown (a @ManyToOne and
    @DescriptionsList) using an Entity not really stored on DB.

    I have a table like this:

         codice char(9) PK
         descrizione varchar(255)
         provincia char(2)

    I have a normal Entity Comune and I would like to have a virtual Entity
    Provincia from a query like: SELECT DISTINCT provincia AS sigla FROM Comune

    This way I could use a @ManyToOne annotation with @DescriptionsList.

    Any suggestion?


  • Laurent Wibaux

    Laurent Wibaux - 2013-09-25

    Hi Francesco,

    I would definitively add one more table called Provincia. I would then make the provincia of Comune a Foreign key in your database schema.
    Then you naturally would have a @ManyToOne


  • Javier Paniza

    Javier Paniza - 2013-09-26

    Hi Francesco,

    I would follow the Laurent advice. However, if you have not the option of creating a new table, you can create a SQL VIEW and map it with a Provincia entity.

    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.


Log in to post a comment.