Hi again!
I'm working on a sample like follows:
Code:
create table RIESGO_PAIS (
   ID bigint not null,
   primary key (ID)
);
create table RIESGO_PAIS_I18N (
   ID bigint not null,
   LOCALE char(2) not null,
   NOMBRE varchar(30),
   primary key (ID,LOCALE)
);
alter table RIESGO_PAIS_I18N
   add constraint RIESGO_PAIS_I18N_ID
   foreign key (ID)
   references RIESGO_PAIS
;
create table dual_RIESGO_PAIS ( zero integer );
insert into dual_RIESGO_PAIS values (0);
create sequence SEQ_RIESGO_PAIS start with 100;
insert into RIESGO_PAIS values (0);
insert into RIESGO_PAIS values (1);
insert into RIESGO_PAIS_I18N values (0,'ES','Bajo');
insert into RIESGO_PAIS_I18N values (1,'ES','Alto');
insert into RIESGO_PAIS_I18N values (0,'EN','Low');
insert into RIESGO_PAIS_I18N values (1,'EN','High');
insert into RIESGO_PAIS_I18N values (0,'PT','Baixo');
insert into RIESGO_PAIS_I18N values (1,'PT','Alto');
That's my hsqldb script.
I wanted to have a POJO like follows:
Code:
/** 
 *        @hibernate.class
 *         table="RIESGO_PAIS"
*/
public class RiesgoPais implements Serializable {
   
   private Long id;
   /** 
     *            @hibernate.id
     *             generator-class="sequence"
     *             column="ID"
     *             type="java.lang.Long"
     *            @hibernate.generator-param
     *              name="sequence"
     *              value="SEQ_RIESGO_PAIS"
     */
   public Long getId() {
      return id;
   }
   public void setId(Long id) {
      this.id = id;
                }
         
   private String locale;
   private String nombre;
   
   // ...and the corresponding getters/setters
         
}
I want my DAO to have the following method:
Code:
List getAll(String locale);
and to be able to pass this test (using the former testing database):
Code:
   public void testListado_i18n() throws Exception {
      List resultado = riesgoPaisDAO.getAll("EN");
      assertEquals(2,resultado.size());
   }
Now I'm stalled because I haven't got any success neither using UserType nor <map>. With <map> I had some success, but not complete.
Does anyone have ANY idea? Of course I'm open to change ANYTHING (including the database schema).
Thanks in advance,
Jose Manuel Beas