Ho folks,
I got an error while running a @SqlResultSetMapping based query.
org.hibernate.MappingException: Unknown SqlResultSetMapping [AAA]
My Stateless Bean:
@Stateless
@SqlResultSetMapping(name="AAA",
entities={
@EntityResult(entityClass=com.certification.entity.ejb.User.class,
fields={
@FieldResult(name="cpf", column="cpf"),
@FieldResult(name="name", column="name")
}
)
},
columns={
@ColumnResult(name="cep")
}
)
public class StatelessBean implements StatelessBeanLocal, StatelessBeanRemote {
@PersistenceContext
EntityManager em;
...
...
...
public Object joinUserWithCEP(Integer cpf) {
try {
Query q = em.createNativeQuery(
"SELECT usr.cpf AS cpf, " +
"usr.name AS name, " +
"e.cep AS cep, " +
"FROM User usr, Endereco e " +
"WHERE usr.cpf = "+cpf+" ",
"AAA");
return q.getSingleResult();
}
catch (Exception e) {
System.out.println("Erro:"+e.getMessage());
return null;
}
}
}
I'm invoking the function from a session bean which is looked up inside a servlet:
StatelessBeanRemote sbr = (StatelessBeanRemote) initialContext.lookup("SCBCD/"+StatelessBean.class.getSimpleName()+ "/remote");
Object cepUser = sbr.joinUserWithCEP(new Integer(1234));
StatelessBeanRemote sbr = (StatelessBeanRemote) initialContext.lookup("SCBCD/"+StatelessBean.class.getSimpleName()+ "/remote"); Object cepUser = sbr.joinUserWithCEP(new Integer(1234));
Somebody has any clues?
Thanks