Finder methods for CMP beans
We do not implement finder method in Bean class for CMP. As such, where do we implement finder methods such as findInRange() method? How does the container implement my custom "find" methods.
Thanks
Using CMP 2.x, your custom finder and select methods are implemented by the container based on the EJB QL query you provide in the ejb-jar.xml. In CMP 1.1, there was no portable way to express the semantics of the query, so most vendors had a vendor-specific syntax for describing the query.
See chapter 27 of the J2EE 1.4 Tutorial for some examples of using EJB QL :
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html
--ken
Kenneth Saks
J2EE SDK Team
SUN Microsystems
Similar Messages
-
Binary Data Type in finder methods for CMP beans
How to write an equivalent ejb-ql query in ejb-jar.xml for a finder method accepting
a byte array as a parameter. The finder method is for a cmp-field mapped to a
database field with binary data typeUsing CMP 2.x, your custom finder and select methods are implemented by the container based on the EJB QL query you provide in the ejb-jar.xml. In CMP 1.1, there was no portable way to express the semantics of the query, so most vendors had a vendor-specific syntax for describing the query.
See chapter 27 of the J2EE 1.4 Tutorial for some examples of using EJB QL :
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html
--ken
Kenneth Saks
J2EE SDK Team
SUN Microsystems -
Using wildcards in custom find methods with CMP beans
Hi,
I'd like to create a custom find method called findByName which accepts a string. I'd typically want to use the string in a '%<name>%' scenario, where the user needn't type in the whole name. Does anybody know what the partial query should look like? I'm not sure how to concatenate the '%' symbol to the string taken in.
Thanks in advance
GillianGillian-
Bind variables are of the form $1, $2, etc., so try using a query stmt like this:
select * from YOURTABLE where name like '%$1%'
Regards,
-Jon -
FAILED TO FIND METHOD FOR HASH ...
here is the trace of the pb... I hope that someone can help me.
java.lang.IllegalStateException: Failed to find method for hash:5806955373774276652
at org.jboss.invocation.MarshalledInvocation.getMethod(MarshalledInvocation.java:367)
at org.jboss.ejb.Container.invoke(Container.java:742)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:135)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:53)
at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:173)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
at $Proxy0.create(Unknown Source)
at server.client.ClientCompteur.main(ClientCompteur.java:46)You must be asking the wrong forum.
This is a forum dedicated to the Sun Java Studio Creator product.
Try here: http://developers.sun.com/forums/
-Alexis -
how many Finder method in Entity bean i can write ?
look below...
public Account findByPrimaryKey(AccountPK key) throws FinderException,
RemoteException;
public Enumeration findByOwnerName(String name) throws FinderException,
RemoteException;here 2 finder methods are there.......i am asking how much freedom i have ? can write as many as finder method i wish ?
say, findXXXX() ?my problem is on the signature of the find
method.
OK let me ask you some other way.
java DOC says
Each enterprise Bean has a home interface. The home
interface must extend the javax.ejb.EJBHome
interface, and define the enterprise Bean type
specific create and finder methods (session Beans do
not have finders).
look it says " finder methods "....right .
so i want to ask 2 question about this phrase . PLZ
do confirm me whether i am right or wrong.
fact 1. finder methods means you can write
any method name which starts with word find
and ONLY find
Example: findABCD( ) , findEFGH(),
findBLAHBLAH()...any thing starts with find[i]
are called finder methods...others are NOT.
is This fact correct ?
Yes.
fact 2. Is not it Strange that i need to
append some letters after the word find to
get a finder method name !! why not wrting a simple
method name ( say abcdfgrty () instead of
findXXXX() which will do the job ??You can... but it has to be called form a findXXXX() method :)
As such there is no problem in writng a
find_ANY_WORDS_HERE() to get a finder method but
problem is why i need to stick to the word
find and append some words after it
t to get a finder method ? if i had to do it
seriously then whats the role of the container ? how
w it is linking ?Once someone takes the pain of going through the EJB specs, he would not have a problem. Imagine each vendor using his own brains and the developer getting bugged with new features in each AS. EJB specs are flexible enough already :) -
How to implement find methods in CMP?
As OC4J does not support EJB-QL, we need to implement the find methods by ourselves. But how? Here is my thought.
1) Still declare the find methods in EJB home, such as
public Collection findBySponsor(String sponsorGuid);
2) Do not add query part to ejb-jar.xml file;
3) In the bean class, implement the find method using JDBC code.
Does CMP allows explicit-implementation of finder methds?
Does CMP allows explicit-call to JDBC code?
Thanks,Henry -- Why go to that trouble? For the near term I would suggest that you just modify the generated
orion-ejb-jar.xml descriptors which will include tags to allow you to either 1) enter a partial criteria or
2) enter a complete SQL statement. This is much less work and when EJB-QL is available with the product,
then you have to only add the EJB-QL to the ejb-jar.xml.
Thanks -- Jeff -
Where to find doc for ChartRenderer bean
does anyone know where documentation for the ChartRenderer bean exists?
I need to know
1) what graph types are available, preferably by seeing graphical examples
2) what data the bean is exactly looking for - I keep getting the error "not enough data to draw chart"
Thanks
GilesHi Giles,
Look at
+Creating JSP Pages
--Working with Web Beans
+----Displaying Rowset Data Using Web Beans
+------Chart Web Bean
The bottom of the page has links to the various types of charts (not with graphics, I'm afraid) and to the kinds of data each chart needs.
Hope this helps,
Avrom
null -
Do you know how to specify custom query strings for finder methods of CMP beans?
null<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Piotr Czarnas ([email protected]):
Do you know how to specify custom query strings for finder methods of CMP beans?<HR></BLOCKQUOTE>
Go look at www.orionsupport.com - they have some instruction on how to do custom finder methods....
Cheers
Ray
null -
I've got a table:
id number primary key,
name varchar2(50),
price number
How can i make finderXXX for this sql query:
select * from table where name like 'beer' and price > 10;
Thank'sgday Max -
For this, you'll need to make some a slight modification to the generated finder methods.
Say you create an entity called Drinks which has the same structure as the table you provide as an example (and can I just say, what a great example you chose ;)
It should go something like this - note, I've not tried this but this is what you need to look at doing:
In the Home interface (DrinksHome) create a findermethod that looks like:
public Collection findByName(String name, Double Price) throws RemoteException, FinderException;
* note we make the return type a collection since it's possible that you may get more than one entity returned.
Go ahead and deploy your EJB.
When you deploy your EJB, OC4J will generate a finder method for this method for you.
Now what you need to do is to modify the generated XML deployment descriptor to tune the query if you will.
OC4J generates the deployment descriptor info it needs for an application in $OC4J/application-deployments.
Go to to $OC4J/application-deployments/<app-name>/<ejb-name> where app-name and ejb-name are specific your deployed EJB.
Open the orion-ejb-jar.xml file. This is the file OC4J uses to describe the deployed beans.
Search through the file until you find the <finder-method> tag.
Amend the query attribute of the finder-method tag to reflect the where clause of the query you want to execute:
query="$name = $1 AND $price > $2"
Now go to the generated SQL string and add the corresponding SQL where condition, using a ? in place of the actual value of the query string above
It would become something like ...
< !-- Generated SQL: "select drinks.id, drinks.name, drinks.price from drinks where drinks.name = ? AND drinks.price > ?" -->
Note that in this query, the where clause matches the query you specified, but you omit the actual values.
Check the method-params defined for the find below and ensure that the order of them lines up with the values you've specified in the finder query.
Stop OC4J and restart it and the new finderMethod should come into effect.
Give that a try and see how you go.
cheers!
-steve-
null -
Universal Entity EJB find/select method for single db table
Hi there.
I'm quite new in bea spheres and my question reflects my small knowledge:
Is there any way to perform "universal" sql query on single database table via find/select methods? This means, that I would like to pass whole WHERE clause to these methods, not just some fields values.
What do I mean?
Normally we define find/select method that looks like this one:
SELECT OBJECT(o) FROM Cities AS o WHERE population>=?1 AND state=?2
We call this a method this way:
finder1 (1000000, 'France')
Method returns collection with objects holding data about cities in France with more than 1000000 inhabitans..
But, I want to define method, that could be called this way:
finder1 ("o.population>=1000000 AND o.state='France'")
This method should be able to perform any query on 'Cities' database table.
I tried with defining find method for following query:
SELECT OBJECT(o) FROM Cities AS o WHERE ?1
but it does not work, of course.
Is there possibility to define method that could be called this way?
I use Bea Weblogic Workshop 8.1 SP3
Message was edited by akla at Oct 23, 2004 5:21 PMHi,
The 'Dynamic Query' feature of WebLogic 8.1's EJB container can help you here. This feature enables you to execute complete EJB QL queries that are constructed on the fly. Check the WebLogic 8.1 documentation for more details.
-thorick -
How to limit a number of rows to be returned in finder method
are there any way we can specify the # of rows to be returned in a finder method for an CMP? how should we specify that within the xml configuration files?
Hi
Sorry to say that u can't do it in the current versions. Only thing u can do is to get all of them and filter them out at the client or servlet layer.
For exapmle if u get the Enumeration (say 25 objects), and u want to show 10 at a time. Keep a variable that keep track of the page number (eg whether it's the first 10 set of records nor next). Keep the Enumeraton that u got in the session (so that u don't get it everytime). When next is pressed, depending on the value of the varaible storing page number skip those number of records in the Enumeratin (eg if u are going to the second page, the number of records to skip will be 1*10 = 10, and get records form 11 to 20 and so on........
What do u say.......this is how I did it in an appilaction.........
Chandan. -
How to call a EJB method from Session bean method
Hi all,
I'm new to J2EE programming. I have a simple doubt .
I have already created a lookup method for EJB bean in Session bean .
My question is how to call a method of an ENTITY bean (say insertRow) from SESSION bean method(Say invoke_insertRow) .
Please provide me an example code .
Thanks in advance.InitialContext ctx = new InitialContext();
GeneralEditor editor = (GeneralEditor) ctx
.lookup("GeneralEditorBean/remote");
GeneralService service = (GeneralService) ctx
.lookup("GeneralServiceBean/remote");
LanMu lm = new LanMu();
lm.setName("shdfkhsad");
editor.add(lm); -
Resource Ref's settings of a CMP bean in SAS PE 8.2 - Deploytool
Dear all,
In the deploytool of SAS8.2, in the [Resource Ref's] tab of a CMP bean do I need to set anything here to enable the CMP bean to connect to the database?
I already have a JDBC source registered in the server and it is called jdbc/mydatasource.
Thanks in advance.Problem solved. For CMP beans, I just need to set the JNDI name of the CMP resource and this name corresponds to the JNDI name of the the JDBC resource registered in the SAS.
But for BMP beans, I will have to add an entry in the [Resource Ref's] tab. The [Coded name] corresponds to the JNDI name used in the code to look up this JDBC resource.
Thanks all. -
Finder Methods - Does xmlbeans support this?
Finder Methods - Does xmlbeans support this?
Hi,
Q1 - Is there currently a mechanism via generated xmlbeans java classes to
find specific data required (from within the java generated methods
provided). For example assuming in the following xml (see below) if one has
already loaded the <main-item> via xmlbean generated java classes, but then
wishes to find the appropriate configs/config within this section of the xml
(i.e. the main-item entry "config" is a reference to one of the "config"
items under "configs") , does XMLBeans currently support this? That is, it
would be nice to have finder methods on the generated java classes so once
you have a <configs> java instance you can issue a finder method for a
<config> item and pass the <config-name> in. For example:
What is available: MainXML.getConfigs().getConfig(23) -> i.e. put in
index,
However what about: MainXML.getConfigs().findConfig ("mainConfig");
Q2 - If there is no support for this within the generated java classes what
is recommended? Via xpath? Have to write your own short java finder classes
which iterate through until the item is found?
ATTACHMENT - XML REFERED TO
============================
< MainXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="xxx.xsd">
<configs>
<config>
<config-name>mainConfig</config-name>
<report_width>1</report_width>
</config>
<config>
<config-name>testConfig</config-name>
<report_width>0</report_width>
</config>
</configs>
<main-config>
<main-item>
<itemName>TestItem</itemName>
<config>mainConfig</config>
</main-item>
</main-config>
</sns_config>
Cheers
Gregthanks Steve
"Steve Traut" <[email protected]> wrote in message
news:[email protected]...
Hello Greg,
To my knowledge, the reference-specific kind of function you're asking for
isn't supported. But if you're writing code on WebLogic Platform 8.1, you
can use XPath/XQuery to accomplish this. Incidentally, your XML belowopens
with MainXML and closes with sns_config, but I'll assume it's MainXML.
To retrieve a main-config/main-item/config element when you know the
config-name element's value, you could use the following expression (where
the mainXml variable is a MainXMLDocument instance):
String queryExpression = "$this/MainXML/configs/config[config-name=
'mainConfig']";
ConfigType[] configs =
(ConfigType[])mainXml.selectPath(queryExpression);
The configs array would contain one item in this case. The second linewould
throw a class cast exception if no results were returned.
Note that XPath predicates aren't supported in XMLBeans outside thecontext
of WebLogic, but simple path expressions are.
Steve
"greg" <[email protected]> wrote in message news:1074728633.92236@ns1...
Finder Methods - Does xmlbeans support this?
Hi,
Q1 - Is there currently a mechanism via generated xmlbeans java classes
to
find specific data required (from within the java generated methods
provided). For example assuming in the following xml (see below) if onehas
already loaded the <main-item> via xmlbean generated java classes, butthen
wishes to find the appropriate configs/config within this section of thexml
(i.e. the main-item entry "config" is a reference to one of the
"config"
items under "configs") , does XMLBeans currently support this? That is,it
would be nice to have finder methods on the generated java classes so
once
you have a <configs> java instance you can issue a finder method for a
<config> item and pass the <config-name> in. For example:
What is available: MainXML.getConfigs().getConfig(23) -> i.e. putin
index,
However what about: MainXML.getConfigs().findConfig ("mainConfig");
Q2 - If there is no support for this within the generated java classeswhat
is recommended? Via xpath? Have to write your own short java finderclasses
which iterate through until the item is found?
ATTACHMENT - XML REFERED TO
============================
< MainXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="xxx.xsd">
<configs>
<config>
<config-name>mainConfig</config-name>
<report_width>1</report_width>
</config>
<config>
<config-name>testConfig</config-name>
<report_width>0</report_width>
</config>
</configs>
<main-config>
<main-item>
<itemName>TestItem</itemName>
<config>mainConfig</config>
</main-item>
</main-config>
</sns_config>
Cheers
Greg -
Finder method to retrieve CMR field?
Hello all!
I have two entity EJBs - one named "Property" and another named "Merchandise".
Property has a one-to-many relationship to Merchandise, and Merchandise is a CMR
field (named "merchandise") in Property. Now I would like to write a finder method
for Property to retrieve the CMR field (Merchandise references). The finder method
is called "findDVD()". The ejb-ql is below:
SELECT DISTINCT OBJECT(merch) FROM Property AS p, IN(p.merchandise) AS merch
WHERE merch.starsMasterTitleId = ?1
AND merch.productTypeCode = 'VIDEO'
AND merch.format = 'DVD'
AND merch.active = 'Y'
AND merch.approved = 'Y'
AND merch.purchaseable = 'Y'
However, I can't seem to get this method to work. Weblogic's EJBC keeps complaining
that the returned collection MUST be of the method owner type - in other words,
I can't return Merchandise references, only Property references.
What am I doing wrong? Is this a limitation in CMR that I didn't know about? Please
help!
I am using WLS 6.1 with SP 1.
Thanks so much!
-BIf you are using ejb2.0 you can do this using a home method and select
method instead of a finder. Finders are limited to returning objects of the
type of ejb they belong to while select methods are not. Select methods
cannot be invoked directly by the clients so you need a home method to wrap
them.
-- Anand
"Brian Wang" <[email protected]> wrote in message
news:3ca3678d$[email protected]..
>
>
Hello all!
I have two entity EJBs - one named "Property" and another named"Merchandise".
Property has a one-to-many relationship to Merchandise, and Merchandise isa CMR
field (named "merchandise") in Property. Now I would like to write afinder method
for Property to retrieve the CMR field (Merchandise references). Thefinder method
is called "findDVD()". The ejb-ql is below:
SELECT DISTINCT OBJECT(merch) FROM Property AS p, IN(p.merchandise) ASmerch
WHERE merch.starsMasterTitleId = ?1
AND merch.productTypeCode = 'VIDEO'
AND merch.format = 'DVD'
AND merch.active = 'Y'
AND merch.approved = 'Y'
AND merch.purchaseable = 'Y'
However, I can't seem to get this method to work. Weblogic's EJBC keepscomplaining
that the returned collection MUST be of the method owner type - in otherwords,
I can't return Merchandise references, only Property references.
What am I doing wrong? Is this a limitation in CMR that I didn't knowabout? Please
help!
I am using WLS 6.1 with SP 1.
Thanks so much!
-B
Maybe you are looking for
-
How to Setup JMS in Siebel Server
Hi Currently we have a Requirement to work with queuing System from JMS Queuing How to Setup the JMS Queuing from Siebel Point of view? Does JMS Should be Installed in Siebel Server? Plz Provide Inputs for How to Set up the JMS Queuing Mechanism and
-
Provide the list of CPU patches for r12.1.2 and r12.1.3.
Hi, can you provide me the exact number of CPU patches for R12.1.2 and R12.1.3, and other recommended patches. thx
-
JSR 234 -- Media Processor Input Types for Sony Ericsson k790
Hi, This method 'getSupportedMediaProcessorInputTypes()' is supposed to return a string array of all the supported media processor input types. However, on the k790, it just returns null. In the docs, to support JSR 234, you're required to support at
-
PL/SQL Development Environments
Hi everybody, We have a PL/SQL IDE that we invite you to download and try out for yourself and appreciate feedback about what people liked or didn't like about it. Please send me comments and feedback. Product information : DreamCoder for Oracle 1.5
-
Installing Leopard on external USB drive
Hi there, I am trying to wipe a drive clean via an external USB drive box. Might somebody explain how I can do this? When I boot on the Leopard DVD I arrive at the drive choice screen and there is a big red "exclamation point" on the external USB dri