[EJB/JBoss] - How to use Group By Clause in JBOSS QL?
by tiwari_p_k
Hi,
I am using EJB 2.1 for my application & using JBOSS 4.0.3 as Application server. Now I am using JBOSS Dynamic QL for "group by" clause as follows:-
-------------------------
public Collection ejbHomeSelectInStates(Set states)
throws FinderException
{
StringBuffer jbossQl = new StringBuffer();
jbossQl.append("SELECT g.orderno ");
jbossQl.append("FROM OrderMaster g ");
jbossQl.append("GROUP BY g.orderno");
Object[] args = states.toArray(new Object[states.size()]);
return ejbSelectGeneric(jbossQl.toString(), args);
}
--------------------------
& I have declared "ejbSelectGeneric" generic method is as follows using XDOCLET:-
--------------------------------------------------
* @jboss.query
* signature="Collection ejbSelectGeneric(java.lang.String ql, java.lang.Object[] params)"
* dynamic="true"
---------------------------------------------------
But when I am accessing function "ejbHomeSelectInStates" in my client, I am getting following error:-
---------------------------------------------
19:02:56,281 INFO [STDOUT] javax.ejb.FinderException: Error compiling ejbql: org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "GROUP" at line 1, column 36.
Was expecting one of:
"," ...
19:02:56,281 INFO [STDOUT] at org.jboss.ejb.plugins.cmp.jdbc.JDBCDynamicQLQuery.execute(JDBCDynamicQLQuery.java:101)
19:02:56,281 INFO [STDOUT] at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCSelectorBridge.execute(JDBCSelectorBridge.java:99)
19:02:56,281 INFO [STDOUT] at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCSelectorBridge.invoke(JDBCSelectorBridge.java:70)
19:02:56,281 INFO [STDOUT] at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:91)
19:02:56,281 INFO [STDOUT] at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:62)
19:02:56,281 INFO [STDOUT] at econify.ordermaster.ejb.OrderMasterCMP$Proxy.ejbSelectGeneric()
19:02:56,281 INFO [STDOUT] at econify.ordermaster.ejb.OrderMasterBean.ejbHomeSelectInStates(OrderMasterBean.java:288)
19:02:56,281 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:02:56,281 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
19:02:56,281 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
----------------------------------------------
I really got bored now as I am trying to solve this problem since last 15 days. Also I searched on net for same, but I am not getting actual solution for it.
PLease help me to solve this problem, as my whole application got stuck due to this.
Thank you.
Pras
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970751#3970751
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970751
19 years, 7 months
[JBoss Seam] - Re: Long Running Conversation Timeouts are never occuring
by knaas
Thanks for the clarifications on this.
If I were developing a new application that allowed users to hold onto tickets for five minutes, I would have originally thought that I could simply use the Conversation timeout. But since this is not the case, it would be important that I understand that I need to design the the ticket timeout behavior into my code.
In order to avoid further confusion on this issue, the documentation in 11.4 and 11.8 should probably be clarified.
E.g in 11.8
anonymous wrote :
| Internal component for Seam page and conversation context management. Always installed.
| * org.jboss.seam.core.manager.conversationTimeout ? the conversation context timeout in milliseconds.
|
Could be changed to something like
anonymous wrote :
| Internal component for Seam page and conversation context management. Always installed.
| * org.jboss.seam.core.manager.conversationTimeout ? the non foreground conversation context timeout in milliseconds. A non foreground conversation is a conversation not associated with the current request.
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970747#3970747
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970747
19 years, 7 months
[JBoss Seam] - MyFaces Tomahawk schedule component does not work.
by sidragon
I am having trouble using the Tomahawk schedule (see http://myfaces.apache.org/tomahawk/schedule.html ) component in a simple Seam application. The component renders the day view regardless of the mode or the addition of any entries to the ScheduleModel. Based on the lack of debugging output, it does not appear to get a reference to my ScheduleModel implementation. (I am subclassing SimpleScheduleModule provided by the Tomahawk library such that its getter and setter methods produce log messages, but again, I get no output.) Others have reported varying degrees of success (see http://mail-archives.apache.org/mod_mbox/myfaces-users/200607.mbox/%3C44B... ) with this component when used with Seam, but I basically get nothing, not even any exceptions.
I have attempted to use both the 1.1.4 and 1.1.5 Tomahawk snapshot releases. I am using Facelets with Seam and JBoss AS 1.0.1.GA. (Other Seam applications work flawlessly, by the way.) Other Tomahawk components are working just fine after following the instructions found at http://wiki.apache.org/myfaces/Use_Facelets_with_Tomahawk . I have added the following tag to my Facelets tag library definition.
<?xml version="1.0"?>
| <!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
| <facelet-taglib>
| <namespace>http://myfaces.apache.org/tomahawk</namespace>
| <!-- ... -->
| <tag>
| <tag-name>schedule</tag-name>
| <component>
| <component-type>org.apache.myfaces.Schedule</component-type>
| </component>
| </tag>
| <!-- ... -->
| </facelet-taglib>
The web application deployment descriptor follows.
<?xml version="1.0" encoding="UTF-8"?>
| <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
| <listener>
| <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
| </listener>
|
| <listener>
| <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
| </listener>
|
| <filter>
| <filter-name>Seam Exception Filter</filter-name>
| <filter-class>org.jboss.seam.servlet.SeamExceptionFilter</filter-class>
| </filter>
|
| <filter>
| <filter-name>Seam Redirect Filter</filter-name>
| <filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>
| </filter>
|
| <filter-mapping>
| <filter-name>Seam Exception Filter</filter-name>
| <url-pattern>/*</url-pattern>
| </filter-mapping>
|
| <filter-mapping>
| <filter-name>Seam Redirect Filter</filter-name>
| <url-pattern>*.seam</url-pattern>
| </filter-mapping>
|
| <context-param>
| <param-name>javax.faces.AUTO_SCROLL</param-name>
| <param-value>true</param-value>
| </context-param>
|
| <context-param>
| <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
| <param-value>client</param-value>
| </context-param>
|
| <context-param>
| <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
| <param-value>.xhtml</param-value>
| </context-param>
|
| <context-param>
| <param-name>facelets.DEVELOPMENT</param-name>
| <param-value>true</param-value>
| </context-param>
|
| <context-param>
| <param-name>facelets.LIBRARIES</param-name>
| <param-value>/WEB-INF/tomahawk.facelets.xml</param-value>
| </context-param>
|
| <servlet>
| <servlet-name>Faces Servlet</servlet-name>
| <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
| <load-on-startup>1</load-on-startup>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>Faces Servlet</servlet-name>
| <url-pattern>*.seam</url-pattern>
| </servlet-mapping>
|
| <servlet-mapping>
| <servlet-name>Faces Servlet</servlet-name>
| <url-pattern>*.jsf</url-pattern>
| </servlet-mapping>
|
| <!--
|
| MyFaces extensions filter. See http://myfaces.apache.org/tomahawk/extensionsFilter.html
| for details.
|
| -->
| <filter>
| <filter-name>MyFaces Extensions Filter</filter-name>
| <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
| <init-param>
| <param-name>maxFileSize</param-name>
| <param-value>20m</param-value>
| </init-param>
| </filter>
|
| <filter-mapping>
| <filter-name>MyFaces Extensions Filter</filter-name>
| <servlet-name>Faces Servlet</servlet-name>
| </filter-mapping>
|
| <filter-mapping>
| <filter-name>MyFaces Extensions Filter</filter-name>
| <url-pattern>/faces/*</url-pattern>
| </filter-mapping>
| </web-app>
JavaServer Faces configuration follows.
<?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN" "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
| <faces-config>
| <application>
| <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
| </application>
|
| <lifecycle>
| <phase-listener>org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener</phase-listener>
| </lifecycle>
|
| <managed-bean>
| <managed-bean-name>today</managed-bean-name>
| <managed-bean-class>java.util.Date</managed-bean-class>
| <managed-bean-scope>application</managed-bean-scope>
| </managed-bean>
|
| <managed-bean>
| <managed-bean-name>foo</managed-bean-name>
| <managed-bean-class>com.mycompany.scheduler.DummyScheduleModel</managed-bean-class>
| <managed-bean-scope>session</managed-bean-scope>
| <managed-property>
| <property-name>mode</property-name>
| <value>3</value>
| </managed-property>
| <managed-property>
| <property-name>selectedDate</property-name>
| <value>#{today}</value>
| </managed-property>
| </managed-bean>
|
| <managed-bean>
| <managed-bean-name>bar</managed-bean-name>
| <managed-bean-class>com.mycompany.scheduler.TriggerScheduleController</managed-bean-class>
| <managed-bean-scope>session</managed-bean-scope>
| <managed-property>
| <property-name>model</property-name>
| <value>#{foo}</value>
| </managed-property>
| </managed-bean>
| </faces-config>
Sample implementation of ScheduleModel.
package com.mycompany.scheduler;
|
| import java.util.Calendar;
| import java.util.Date;
|
| import org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
| import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
| import org.apache.myfaces.custom.schedule.model.ScheduleModel;
| import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
|
| public class DummyScheduleModel extends SimpleScheduleModel
| {
| public DummyScheduleModel()
| {
| super();
| final Calendar calendar = Calendar.getInstance();
| calendar.setTime(new Date());
| final DefaultScheduleEntry entry = new DefaultScheduleEntry();
| entry.setId("dummyEntry");
| entry.setStartTime(calendar.getTime());
| calendar.add(Calendar.MINUTE, 45);
| entry.setEndTime(calendar.getTime());
| entry.setTitle("Test MyFaces schedule component");
| entry.setSubtitle("my office");
| entry.setDescription("We need to get this thing out of the sandbox ASAP.");
| setMode(ScheduleModel.WEEK);
| addEntry(entry);
| refresh();
| System.err.println("Created DummyScheduleModel instance with an event on "
| + entry.getStartTime() + ".");
| }
|
| public boolean isEmpty()
| {
| System.err.println("Called isEmpty (" + super.isEmpty() + ")");
| return super.isEmpty();
| }
|
| public Date getSelectedDate()
| {
| System.err.println("Called getSelectedDate (" + super.getSelectedDate() + ")");
| return super.getSelectedDate();
| }
|
| public ScheduleEntry getSelectedEntry()
| {
| System.err.println("Called getSelectedEntry (" + super.getSelectedEntry() + ")");
| return super.getSelectedEntry();
| }
|
| public boolean isEntrySelected()
| {
| System.err.println("Called isEntrySelected (" + super.isEntrySelected() + ")");
| return super.isEntrySelected();
| }
|
| public int getMode()
| {
| System.err.println("Called getMode (" + super.getMode() + ")");
| return super.getMode();
| }
|
| public Object get(int i)
| {
| System.err.println("Called get (" + super.get(i) + ")");
| return super.get(i);
| }
|
| public boolean containsDate(Date date)
| {
| System.err.println("Called containsDate (" + super.containsDate(date) + ")");
| return super.containsDate(date);
| }
|
| public int size()
| {
| System.err.println("Called size (" + super.size() + ")");
| return super.size();
| }
| }
My simple "controller" class.
package com.mycompany.scheduler;
|
| import java.text.DateFormat;
| import java.text.SimpleDateFormat;
|
| import org.apache.myfaces.custom.schedule.model.ScheduleModel;
|
| public class TriggerScheduleController
| {
| private ScheduleModel model;
|
| public ScheduleModel getModel()
| {
| System.err.println("Giving model " + model);
| return model;
| }
|
| public void setModel(final ScheduleModel model)
| {
| System.err.println("Got model " + model);
| this.model = model;
| }
| }
Note that I started with TriggerScheduleController as a stateful session bean. The class had the following annotations.
@Stateful
| @Name("triggerSchedule")
| @Scope(SESSION)
And these methods.
@Create
| public void create()
| {
| setModel(new DummyScheduleModel());
| getModel().setMode(ScheduleModel.MONTH);
| }
|
| @Destroy
| @Remove
| public void destroy()
| {
| }
The view, browse.xhtml, contains the following (note it fills in a template).
<?xml version="1.0" encoding="utf-8"?>
| <ui:composition xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
| xmlns:s="http://jboss.com/products/seam/taglib" xmlns:t="http://myfaces.apache.org/tomahawk"
| xmlns:ui="http://java.sun.com/jsf/facelets" template="/template.xhtml">
| <ui:define name="title-text">Schedule</ui:define>
|
| <ui:define name="content">
| <div class="Section">
| <h2>
| <span>Browse</span>
| </h2>
|
| <h:form>
| <t:schedule id="triggerSchedule" value="#{bar.model}" rendered="true" theme="evolution" tooltip="true"
| visibleEndHour="18" visibleStartHour="8" workingEndHour="17" workingStartHour="9" readonly="false"/>
| </h:form>
| </div>
| </ui:define>
| </ui:composition>
When exploded, my deployment in JBoss appears as follows.
/
| scheduler.jar!/
| META-INF/
| ejb-jar.xml
| persistence.xml
| seam.properties
| (project classes)
| scheduler.war/
| WEB-INF/
| lib/
| tomahawk-1.1.[45].jar
| facelets-1.1.11.jar
| commons-lang-2.1.jar
| el-ri.jar
| jboss-seam-ui-1.0.1.GA.Jar
| el-api.jar
| web.xml
| components.xml
| pages.xml
| faces-config.xml
| tomahawk.facelets.xml
| browse.xhtml
| template.xhtml
| META-INF/
| application.xml
| jboss-app.xml
| jboss-seam-1.0.1.GA.jar
| tomahawk-1.1.[45].jar
|
And for reference, application.xml contains this.
<?xml version="1.0" encoding="UTF-8"?>
| <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee
| http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
| <display-name>Scheduler</display-name>
| <module>
| <web>
| <web-uri>scheduler.war</web-uri>
| <context-root>/scheduler</context-root>
| </web>
| </module>
| <module>
| <ejb>scheduler.jar</ejb>
| </module>
| <module>
| <java>jboss-seam-1.0.1.GA.jar</java>
| </module>
| <module>
| <java>tomahawk-1.1.[45].jar</java>
| </module>
| </application>
|
Of course, when I was using a stateful bean, I was passing that through the value attribute of t:schedule. In that case, I have be supplying the @Out annotation on the model field. I have even tried making the bean extend SimpleScheduleModel itself and pass it directly. The configuration you see here is to mimick the known-working example provided by the MyFaces project (their examples work when deployed in JBoss).
If I upgrade the MyFaces library in JBoss's Tomcat deployment (tried both 1.1.4 and 1.1.5 snapshots), things become even more broken. And again, as mentioned, no messages with the exception of the println statement in the constructor are produced at runtime.
So, does anyone have any idea what I am doing wrong?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970745#3970745
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970745
19 years, 7 months