IN Operator in ejb ql
I'm trying to write a query that use the in operator:
@NamedQuery(name="findAnswersByLoginIdAndQuestionList", query="select object(o) from Answers o Where o.loginId = :loginId AND o.questionId IN :questionId")but I'm getting an error:
Exception Description: Syntax Recognition Problem parsing the EJBQL [select object(o) from Answers o Where o.loginId = :loginId AND o.questionId IN :questionId]. The parser returned the following [unexpected token: IN].
What am I doing wrong here?
I'm looking through some documentation at http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/EJBQL5.html#72299
It looks to me like the IN does not support variables, the list must contain string literals. Quote:
An IN expression determines whether or not a string belongs to a set of string literals. Here is the syntax of the IN expression:
in_expression ::=
single_valued_path_expression
[NOT] IN (string_literal [, string_literal]* )
I'm sure there's some trickery that can get it to do what you want, though.
Also, no matter what you try, I would definitely suggest that you put the ( ) around your IN list. I assume in your example, questionId was a comma separated list, and the questionId string contained the parentheses. I don't think that will work.
Also, I suggest looking at the IN that is part of the FROM clause, to see if it does what you wan.
Message was edited by:
Michael_Ebbert
Similar Messages
-
UNION operator in ejb 3.0
Hi All,
I have to use UNION operator in my ejb ql. My underlying database is MySQL.
My ejb ql is
SELECT s from eee s where s.name like 'XXX'
UNION
SELECT t from eee t where t.default_id = 'XXX'
union is on the same entitybean.
In my eee entity bean I have tried
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
Ejb ql doesnot return the expected results.
Could someone please help me out with UNION operator in ejb 3.0
Thanksyou should have little problems, but just how little is container specific. I successfully run JEE 1.4 stuff on JBoss 5.1 for example without having to make any configuration changes. Heck, I mix that technology with EJB 3 tech, even having shared container managed transactions.
BTW: you mean JEE5, not J2SE 1.5. Big difference in what they represent. -
Performing database operations using EJB 3.0
I need to create a session bean that will perform operations on backend database. I am new to EJB 3.0 and need a gentle guidance to the solution
This is what I believe is suppose to be done
1. Create stateless bean interface marking operations.
2. Create bean implementation for above
3. Init stage will require me to connect to the Oracle database. Now am confused how will it get the connection details? Is there a way to extract the url username and password using resource bendle which can be accessed from within bean implementation?
4. Bean method will perform update, read oprations
5. Predestroy will close the connection
6. A client will simply call this ejb with some input parameter(s)
Please let me know if am doing anything wrong hereIf you use EJB technology for which it is designed, the container (server) will manage the transaction (and also the connections to the database) for you, so no creation or cleanup of connections on your part. I advise you to read into JPA which is designed to be used in conjunction with EJB tech. The books Enterprise Javabeans 3.0 and Pro EJB 3: the Java Persistence API may help you a lot.
-
File IO operation in EJB (Session Bean)
Hi all,
Requirement : Read contents of a text file and upload the same to Oracle database (table).
I have created a Java class (application kind of) which opens, reads a file and transfers its data to a Oracle table.
Can I instantiate the same class within a Session Bean to perform the same operation or as per the EJB Restrictions this is not supposed to be done?
EJB Specifications 2.1 pdf guide
(refer 25.1.2 Programming restrictions
An enterprise bean must not use the java.io package to attempt to access files and directories in the file system. The file system APIs are not well-suited for business components to access data. Business components should use a resource manager API, such as JDBC, to store data.
Awaiting ur responses at the earliest.
Thanking in advance,
SeeteshHi Kenneth,
Thks for ur post.
I have coded the same using Weblogic App Server 7.0 ie a jsp invoking a java class (FileIO.class)(using jsp:useBean) and writing which does the IO operation and this works just fine.
Will this work by replacing the jsp with a Session Bean.
ie Session Bean's business method executing the method in the FileIO.class
Rgds,
Seetesh -
How to add an EJB to the Business Operation's EJB list?
I have made a session stateless EJB that have just one single business
method and I want to call that method from my workflow template definition.
So, I need it to be added to the /JNDI Name for Session EJB/ combo box in
the Define Business Operation window. I tried by simply deploying the ejb by
using the WLS console app but I didn't get it in the combo box list, what I
got was an exception in the WLS6:***** ASSERTION FAILED *****[ Unable to
load remote interface: java.lang.ClassNotFoundException:
atlante.Prueba ]Make sure your EJB is configured in the same Application as
the WLPI codeI have been trying to find an elegant way to add my ejb to the
WLPI Application in the console but i haven't found any, so what I had to do
was add the definition of my ejb to the <Application... name="WLPI
Application"> element in config.xml. It works fine, but I don't feel
comfortable doing that and I also think that there must be a descent way to
do that.so, the question is, how?
I will appreciate any help on this
regards
IsraelI have made a session stateless EJB that have just one single business
method and I want to call that method from my workflow template definition.
So, I need it to be added to the /JNDI Name for Session EJB/ combo box in
the Define Business Operation window. I tried by simply deploying the ejb by
using the WLS console app but I didn't get it in the combo box list, what I
got was an exception in the WLS6:***** ASSERTION FAILED *****[ Unable to
load remote interface: java.lang.ClassNotFoundException:
atlante.Prueba ]Make sure your EJB is configured in the same Application as
the WLPI codeI have been trying to find an elegant way to add my ejb to the
WLPI Application in the console but i haven't found any, so what I had to do
was add the definition of my ejb to the <Application... name="WLPI
Application"> element in config.xml. It works fine, but I don't feel
comfortable doing that and I also think that there must be a descent way to
do that.so, the question is, how?
I will appreciate any help on this
regards
Israel -
Does OC4J support "LIKE" operation in ejb-ql?
I have a sql in ejb-jar.xml:
<query>
<query-method>
<method-name>findByZoneidTypeLnameInfo1</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>int</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[ SELECT OBJECT(a) FROM rrdata AS a WHERE a.zoneid = ?1 AND a.type = ?2 AND a.lname = ?3 AND a.info1 LIKE 'udns%.ultradns.net.' ]]>
</ejb-ql>
</query>
When compiling, I got an error:
com/sun/ejb/ejbql/StringLiteral
EJB QL statement : 'SELECT OBJECT(a) FROM rrdata AS a WHERE a.zoneid = ?1 AND a.
type = ?2 AND a.lname = ?3 AND a.info1 LIKE 'udns%.ultradns.net.''
EJB QL method : public abstract java.util.Collection com.ultradns.j2ee.compon
ents.ultradns.rrdata.ejb.RrdataHome.findByZoneidTypeLnameInfo1(java.lang.String,
int,java.lang.String) throws javax.ejb.FinderException
at com.sun.ejb.ejbql.parser.EjbQLParser.parse(EjbQLParser.java:226)
at com.sun.ejb.ejbql.EjbQLDriver.parse(EjbQLDriver.java:86)
at com.sun.ejb.sqlgen.SQLGenerator.generateSQLForEjbQLQueries(SQLGenerat
or.java:628)
at com.sun.ejb.sqlgen.SQLGenerator.generateSQL(SQLGenerator.java:270)
at com.evermind.server.ejb.deployment.EJBPackage.init(EJBPackage.java:19
47)
at com.evermind.server.ServerComponent.init(ServerComponent.java:224)
at com.evermind.server.ejb.EJBPackageDeployment.getPackage(EJBPackageDep
loyment.java:645)
at com.evermind.server.ejb.EJBContainer.postInit(EJBContainer.java:513)
at com.evermind.server.Application.postInit(Application.java:429)
at com.evermind.server.Application.setConfig(Application.java:136)
at com.evermind.server.ApplicationServer.addApplication(ApplicationServe
r.java:1479)
at com.evermind.server.ApplicationServer.initializeApplications(Applicat
ionServer.java:1436)
at com.evermind.server.ApplicationServer.setConfig(ApplicationServer.jav
a:1099)
at com.evermind.server.ApplicationServerLauncher.run(ApplicationServerLa
uncher.java:93)
at java.lang.Thread.run(Thread.java:484)
at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:49)
Error in application dnsmanager: Error loading package at file:/C:/java/oc4j/j2e
e/home/applications/dnsmanager/ejb/, Failure to initialize EJBQL descriptors: co
m/sun/ejb/ejbql/StringLiteral
EJB QL statement : 'SELECT OBJECT(a) FROM rrdata AS a WHERE a.zoneid = ?1 AND a.
type = ?2 AND a.lname = ?3 AND a.info1 LIKE 'udns%.ultradns.net.''
EJB QL method : public abstract java.util.Collection com.ultradns.j2ee.compon
ents.ultradns.rrdata.ejb.RrdataHome.findByZoneidTypeLnameInfo1(java.lang.String,
int,java.lang.String) throws javax.ejb.FinderExceptionI would suggest to try
"from Brukerkonto as o"
instead of
"from Brukerkonto o" -
Using SQLJ in Session EJB (WebLogic 6.1) - connection giving ClassCastError
Hi All
I have one SQLJ file which i have translated to a .java file and , its contents ( methods) have ben pasted in a Session bean , which is deployed in Weblogic 6.1 App Server .
Now in Session bean i am using the jndi lookup of my datasource in Weblogic and creating a conection to the database .
with this connection the normal jdbc methods connects to the databse , but the sqlj method gives a class cast error when i try to allocate the Connection Object to the DefaultContext .
*********************** CODE SNIP ********************
new sqlj.runtime.ref.DefaultContext m_dx = new sqlj.runtime.ref.DefaultContext(conn);
sqlj.runtime.ref.DefaultContext.setDefaultContext(m_dx);
"conn"is the jndi dsn's
DataSourse.getConnection ();
/*In the Method */
sqlj.runtime.ConnectionContext __sJT_connCtx = sqlj.runtime.ref.DefaultContext.getDefaultContext();
the bean compiles , and is deployed sucessfully , and after lookup the conn and m_dx objects are created sucessfully , but when the sqlj method runs it gives a class cast exception .
java.lang.ClassCastException: weblogic.jdbc.rmi.SerialConnection
Is it that Weblogic will not support SQLJ translated code ?
Please help me out , Will i be able to use the Good features of SQLJ in my EJB beans to be Deployed in Weblogic 6.1 Application Server .
ThanksHi Nicolas,
Have you tried to turn on testOnReserve setting of the coneection pool?
Regards,
"Nicolas Devos" <[email protected]> wrote in message
news:3c5fa916$[email protected]..
>
Hi,
I am using weblogic 6.1 and oracle 8.1.6, and experiences
problems with connections pools and database crash.
When the database server crashes during an EJB transactions,
the connection used by that transaction seems to be lost and
is never rebuilt when the database server restarts, therefore
the number of connections within the pool shrinks thoroughly
if I have several connections used while the database crashes
or is shutdown for maintenance.
If this db crash takes time to recover, all connections
are destroyed and the pool become unusable.
As soon as all connections have been 'destroyed' I have
the following exception:
'connection pool - none available' when trying to get
a connection.
When I restart the database server, the pool does not rebuilt
itself.
(I am using a test table to test the presence of the database
with a frequency set to 60s)
I did the same operation without EJB transactions and the pool
could rebuilt itself after the database has been restarted.
I had that problem with weblogic 6.0 already and in the
release notes of 6.0_sp2, 2 issues are fixed concerning
the pool fail-over: 044223 and 041793.
I would like to know if these issues are fixed in 6.1 as well,
and if they are related to my problem (Their description is
quite short).
Thank you
Nicolas -
Is it possible to use in EJB QL syntax "a.id IN (1,2,3,4)"
I want to execute query like
public Collection findbyIds(Integer[] ids);
SELECT ... FROM Orders o WHERE o.id IN (?1) so, it become
SELECT ... FROM Orders o WHERE o.id IN (1,2,3,4)
Is that possible?I've used 'IN' operator in EJB Finder ejb-ql and it doesn't work. There isn't compile error when building EJB_project.jar, but 'IN' isn't relevant in ejb-ql. Try to change your SQL statement or use weblogic-ejb-ql.
Best regards: George Moykin -
Hai All.
I got an error when put this EJB-QL syntax :
<query>
<query-method>
<method-name>findByName</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>SELECT DISTINCT object (a) FROM DummyData a WHERE a.name LIKE ?1</ejb-ql>
</query>
Seems like this method cannot take an arguments, because it runs well when I change the <ejb-ql> syntax with harcode query like this :
<ejb-ql>SELECT DISTINCT object (a) FROM DummyData a WHERE a.name LIKE %FOO%</ejb-ql>
Is there something wrong with my first syntax?
or the EJB-QL cannot take an arguments for LIKE operator in EJB 2.0??
Below is the error output
Auto-deploying file:/C:/NS/jdev/TAX_WORKSPACE/TAX_PROJECT/classes/ (No previous deployment found)... Encountered "a . birthdate LIKE ?1" at line 1, column 7.
EJB QL method : public abstract java.util.Collection gov.tax.business.registration.IEbDummyLocalHome.findByName(java.lang.String) throws javax.ejb.FinderException
com.sun.ejb.ejbql.EjbQLQuery
com.sun.ejb.ejbql.parser.EjbQLParser.parse(com.sun.ejb.ejbql.SymbolTable, com.sun.enterprise.deployment.PersistenceDescriptor, java.lang.reflect.Method, java.lang.String)
Thanx in advanceHi,
You can achieve this by overriding EJB-QL in orion-ejb-jar.xml file. Please look at
http://otn.oracle.com/docs/products/ias/doc_library/903doc_otn/generic.903/a97677/ql.htm#1005714
So you can have something like
<finder-method query="$name like $1"> in orion-ejb-jar.xml
and a dummy (but valid) ejb-ql in ejb-jar.xml, like
<ejb-ql>SELECT DISTINCT object (a) FROM DummyData a WHERE a.name =?1</ejb-ql>
Hope this helps,
Neelesh
OTN Team @ IDC -
Hi
Am I the only one that noticed the lack of instanceof operator in EJB QL?
Suppose I have "class B extends A", and I want to select the A entities which are not A, for instance. I'd expect to be able to do:
"from A a where not(a instanceof B)"
There are numerous other usages I have encountered and had to workaround it.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Amit Kasherselect a from A a where a not in (select b from B b) might work.
-
Shutdown class; unable to access EJBs/JDBC
I have a fundamental question here, and for which I have not found any documentation
on BEA's own documentation center.
Can I, or can I not invoke operations on EJBs/JDBC/JNDI etc from my implementation
of weblogic.common.T3ShutdownDef??
Startup classes can in general access all resources, and they can also invoke
services on EJBs if LoadBeforeAppDeployments is false (the default) in config.xml.
However, the same does not seem to be true for shutdown classes. I am unable to
access services from a shutdown class.
As soon as I invoke weblogic.Admin with SHUTDOWN as the command, the server transitions
to STANDBY state and then the shutdown class is invoked.
The session bean is found and available, but when a transaction is sought to be
created to execute a finder on an EntityBean within the SessionBean, I get an
exception that transactions cannot be created in the Standby state of the server.
To get around this, I thought I will get a reference to the DataSource from JNDI
and execute a query on the JDBC connection, and that failed as well, saying that
JDBC connections are also not available.
Am I doing something wrong here? Or is this a bug.
I am developing on WLS 7.0.
Thanks!
Vivek.quote:
Please help me understand why. I have the easeToLoc setup to
received input variables:
The syntax of ActionScript dictates that you refer to the
callback function in the way that I pointed out. The only argument
that is passed to that listener function is an event object. This
is what it expects, nothing more. Take a look at the
docs
for more info, specifically the categories under Programming
ActionScript 3.0 -> Handling Events.
Looking at navPanelClose() and navPanelOpen(), the values
you're trying to pass seem more like constants to me, not
variables. So why not declare them as constants within this class
and refer to them as such within easeToLoc()? If you truly want to
use variables, perhaps creating a separate utility class to handle
this logic will work better.
When trying to access a method within one class from another
...let's say you want to access myMethod() within class MyAClass
from class MyBClass. You could:
1. Declare myMethod() as static and then refer to it from
anywhere after importing MyAClass. So you can call
MyAClass.myMethod() without having to instantiate MyAClass. This is
what you're trying to do here, I think.
2. Have class MyBClass extend MyAClass where myMethod() is
public or protected and MyBClass is in the same package as MyAClass
when it's declared as protected. For this to work you'd have to
instantiate MyBClass.
TS -
JNDI / EJB deployment and clustering
I'm aware that replication isn't supported for stateful EJBs. But the
"serialization of the handle isn't supported" statement has me concerned.
So I'm looking for a little clarification on this scenario:
Let's say I've got a stateful session bean, which is accessed from a
servlet. For performance reasons, you want to find the colocated instance -
the smart stub should do this, right? To have it colocated in all
instances, then I need to deploy it into each server of the cluster. This
essentially bind()/rebind()'s (whichever call the container does during a
deploy operation) the EJB n times. Does each of those JNDI bind/rebind
calls "overwrite" the previous one, or does the replicated JNDI tree somehow
"keep" all the entries?
What happens if I bind/rebind "non-cluster enabled" objects into the JNDI
tree in each server to the same name (like a reference data table - doesn't
really need to be an RMI object, one per server is fine)? Will they get
"overwritten"? Should I need to take into account the server name when
binding into the tree, and then also use that for subsequent lookups?
Thanks for any input!
--Jason
Guys,
Thanks for the information.
The problem was that classpath, some other packages required for the Bean
were not in the weblogic\classes directory.
so that was it.
Thanks
/selvan
Murali Krishna Devarakonda wrote in message
<7qjkr1$7dl$[email protected]>...
Are you using the HOT DEPLOY feature(startweblogic.bat does it)?
Then you could go to the WebLogic Console, select the Bean, and Redploy.
You could also do it from a command line utility "weblogic.deploy".
If you didn't start the server with the hot deploy, you need to restartyour
server after any changes.
You should read the weblogic docs on the Hot Deploy feature. A different
classloader is used for it. Also, the standard weblogic classpath cannot
coexist with it.
Hot Deploy uses: (assuming your weblogic installation is in D:/WebLogic
D:\WebLogic\classes/boot
It will throw an exception if you have D:\weblogic\classes or
D:\WebLogic\lib\weblogicaux.jar in the system classpath. You need to use
the weblogic.classpath instead.
Regards,
Murali Krishna Devarakonda
Tamilselvan Ramasamy <[email protected]> wrote in message
news:7qi0ln$kpc$[email protected]..
Hello,
I have created bunch of EJB Components and deployed for WLS4.0 using the
following way. It works fine under WLS4.0
To compile java code -> javac *.java
Create SER file -> java weblogic.ejb.utils.DDCreator -d .
DeploymentDescriptor.txt
Create JAR file -> jar cmf manifest Bean.jar /directory
EJBC and deployment -> java weblogic.ejbc -d /targetDirectory Bean.jar
and also add an entry in the welogic.properties file
weblogic.ejb.deploy= ...
When I do the samething in the WLS4.5, it doesn't work, first of all,
JNDI
is not finding the home interface. It throws a naming Exception
please give me an idea hw do I deploy my Beans in the WLS4.5 using the
command line option. I don't have Visual Cafe to do that automatically.So
I
have to do that manually.
Thanks
/selvan
Captura Software Inc
[email protected] -
Is there ejb TimerService in Weblogic8.1 server?
Hi,
In J2ee1.4, there is a TimerService in "javax.ejb" folder. The TimerService interface
provides enterprise bean components with access to the container-provided Timer
Service. The EJB Timer Service allows entity beans, stateless session beans, and
message-driven beans to be registered for timer callback events at a specified
time, after a specified elapsed time, or after a specified interval.
I wonder if there is a similar mechanism available in Weblogic8.1 server now to
let us achieve
Timer operations for ejbs.
Thanks,
Clark WangWeblogic 8.1 supports only J2EE1.3, since J2EE1.4 is not yet finalized.
However there may be a timer service or a scheduled messaging service in the
server,
but that would be Weblogic-specific.
Regards,
Robert Varga
"Clark Wang" <[email protected]> wrote in message
news:3fb338a9$[email protected]..
>
Hi,
In J2ee1.4, there is a TimerService in "javax.ejb" folder. TheTimerService interface
provides enterprise bean components with access to the container-providedTimer
Service. The EJB Timer Service allows entity beans, stateless sessionbeans, and
message-driven beans to be registered for timer callback events at aspecified
time, after a specified elapsed time, or after a specified interval.
I wonder if there is a similar mechanism available in Weblogic8.1 servernow to
let us achieve
Timer operations for ejbs.
Thanks,
Clark Wang -
EJB persistence question...
Hi experts,
I need to do the following operations over a table:
1. Delete all data table.
for example by using SQL: delete from table2. Update several rows at the same time.
for example by using SQL: update MY_TABLE set MY_FIELD = 'New value for the column field'3. Insert several rows at the same time.
for example by using SQL: insert into MY_TABLE select * from MY_TABLE2easiest by using SQL, but using EJBs......!!!
I know that a EJB entity maps one row at the same time and the basic methods of the bean life cycle (create, store, remove, etc) only applies for the row mapped.
How can I do this operations over several rows in a table using EJBs ??
The only manner that I know is to do a loop for to iterate over each entity bean by making a findByPrimaryKey, sets bean attributes and then to wait for the ejbStore, ejbRemove, etc.
is there another way or pattern for manage a table (several rows) in order to avoid this loop...?
thanks in advanceI know that a EJB entity maps one row at the same
time and the basic methods of the bean life cycle
(create, store, remove, etc) only applies for the row
mapped.Exactly !
How can I do this operations over several rows in a
table using EJBs ?? It's not possible.
The only manner that I know is to do a loop for to
iterate over each entity bean by making a
findByPrimaryKey, sets bean attributes and then to
wait for the ejbStore, ejbRemove, etc.
is there another way or pattern for manage a table
(several rows) in order to avoid this loop...?No. Therefore I would advice to use SQL for those operations.
EJB's won't work well, because of performance problems. -
Hi,
We had to write data to files during startup (creation) of our ejb session beans to implement our business logic.
But I heard performing IO operations from ejb is not adviceable.
Can anyone let me know the shortcomings (that we have to be aware) of doing io from session bean and also is there any alternate solution for this.?
Thanks,
RajaHi Raja,
You have two main issues:
Location independance. In a distributed application is the file that you are writing to the same file. e.g. A session bean can be running on any server.
Resource management. The container is not managing the resource so you have to, there are concurrency issues and transactional issues.
If you can avoid using a file avoid it. e.g. Memory cache, database. If you need a file then maybe look at a JCA adapter.
John.
Maybe you are looking for
-
Hello Friends, I need a help regarding how to load a class manually. i have the class name -- TestClass1 and Path - com.apps.classes Thank you
-
Access Snow Leopard Folders from Boot Camp running Vista
Hi. I have a MacBook with a three partitioned hard drive. 2 partitions are HFS+, 1 for Snow Leopard and 1 for storage of my music, photos and video files etc. The 3rd is a Boot Camp partition on which I have Windows Vista installed. I find that I can
-
PO and General Ledger Balance receiving accounts
Hello, Can we compare report total of 'Receiving Value Report' (PO) (receiving a/c) with GL>Inquiry>Account, YTD (enter details and show balances button which displays YTD (receiving a/c))? If yes, what are the points we need to take care of. Thanks
-
Hello all, I need some information of segment builder and hope you can assist me: if I combine different attributes with AND / OR does the segment builder set brackets? So if I choose attribute A or C and drag it to the profile and afterwards I combi
-
I open itunes "importing itunes music library.xml" then nothing???
so itunes is my everyday sanctuary.. I listen to all kinds of music.. Im also a great DJ!! that is until now:( yesterday i tried to open itunes and it says "importing itunes music library".. but it goes on for like an hour.. so i clicked "stop".. and