[Persistence, JBoss/CMP, Hibernate, Database] - Named query not known error with Jboss/EJB3
by elsieq
Hi,
I am using jboss-4.0.5 GA. When I try to use a named query, I am getting a hibernate mapping exception "Named query not known". The steps to create and use a named query with EJB3 seem very simple so I don't know where I'm going wrong.
I have defined the named query with the entity like this:
@Entity
@NamedQuery(name="findGroupsByMemberId",
query="select gm from Groupmember gm where gm.memberIdKy = :memberId")
@Table(name = "groupmember", catalog = "cmpe275db", uniqueConstraints = {})
public class Groupmember implements java.io.Serializable {
I then use that query in a stateless session bean like this:
Query q = em.createNamedQuery("findGroupsByMemberId");
q.setParameter("memberId",stumblerId);
Since I am coding to EJB3 and also using Eclipse with the JBossIDE plugin, that is pretty much all I need to do. As far as I know, I don't have to deal with mapping files or anything else like that.
Any clues or insights would be really appreciated.
Regards,
-Elsie Qureshi
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4037635#4037635
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4037635
19 years
[JBoss Seam] - Re: Questions on resourceBundle
by fernando_jmt
So, I think the MessageFactory class you have is not needed. You can use Seam org.jboss.seam.core.FacesMessages class instead.
Below you can see an example I have:
|
| @Name("converters")
| public class Converters {
|
| @Transactional
| public Converter getRoleConverter() {
| return new Converter() {
|
| @Transactional
| public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String string) throws ConverterException {
| Role role = ((EntityManager) Component.getInstance("entityManager")).find(Role.class, string);
| if (role != null)
| return role;
| else {
| FacesMessage message = FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR, "Common.error.selected_NotFound", null, "");
| throw new ConverterException(message);
| }
| }
|
| public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object object) throws ConverterException {
| return ((Role) object).getName();
| }
| };
| }
|
| }
|
|
Common.error.selected_NotFound is a key in the messages.properties.
HTH.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4037626#4037626
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4037626
19 years
[JBoss Seam] - Re: Questions on resourceBundle
by hasc
so far i' ve tried the following:
in faces-config.xml:
<application>
| <locale-config>
| <default-locale>de</default-locale>
| <supported-locale>de</supported-locale>
| <supported-locale>en</supported-locale>
| <supported-locale>fr</supported-locale>
| </locale-config>
| <message-bundle>messages</message-bundle>
| </application>
in the *.ear i have the files messages.properties, messages_en.properties, messages_fr.properties, messages_de.properties in the directory WEB-INF/classes
in the getAsObject() Method of the CustomConverter i throw an Exception:
...
| FacesMessage message = MessageFactory.getMessage(FacesMessage.SEVERITY_ERROR, "AreaConverterPositiveNumber");
| throw new ConverterException(message);
and the MessageFactory class is the following:
public class MessageFactory {
|
| public static FacesMessage getMessage(FacesMessage.Severity severity, String id) {
| String summary = "???" + id + "???";
| String detail = null;
|
| FacesContext context = FacesContext.getCurrentInstance();
| String name = context.getApplication().getMessageBundle();
| Locale locale = context.getViewRoot().getLocale();
| ResourceBundle bundle = ResourceBundle.getBundle(name, locale);
| summary = bundle.getString(id);
| detail = bundle.getString(id + "Detail");
|
| return new FacesMessage(severity, summary, detail);
| }
| }
i get the following error message:
2007-04-16 17:53:48,828 ERROR [STDERR] 16.04.2007 17:53:48 com.sun.faces.lifecycle.ProcessValidationsPhase execute
| WARNUNG: Can't find bundle for base name messages, locale de
| java.util.MissingResourceException: Can't find bundle for base name messages, locale de
| at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:836)
| at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:805)
| at java.util.ResourceBundle.getBundle(ResourceBundle.java:576)
| at gmp.webapp.converter.MessageFactory.getMessage(MessageFactory.java:18)
| at gmp.webapp.converter.AreaConverter.getAsObject(AreaConverter.java:90)
| at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:188)
| at javax.faces.component.UIInput.getConvertedValue(UIInput.java:943)
Would be great if someone could help me with that.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4037623#4037623
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4037623
19 years