CMP PK Sequence generated by Bean Self Cache !!

Hi All,
In WL6.1, one can mention the name of the sequence and the DB in the cmp-rdbms-jar.xml
to use the sequence generated number to use as a primary key.
Though my work is being done by the WL server but still WL server is hitting the
DB for each insert.
There are a couple of discussions listed on theserverside.com, but most of them
fail for a clustered environment.
Can anyone please suggest me a solution where the WL server would cache the keys
instead of hitting the DB for each insert ?
Thanks in advance for your help !!
Regards
-Rais

Hi,
I performed a test and ran 3 scenarios(inserting 1000 records).
1. SEQUENCE INCREMENT BY 10 And key-cache-size = 1.
Time taken = 13 seconds
Records were inserted as 1,11,21,31.....
2. SEQUENCE INCREMENTED BY 10 And key-cache-size = 10
Records were inserted as 1,2,3,4,5...
Time = 8 seconds
3. SEQUENCE INCREMENTED BY 1 And key-cache-size = 10
I got the duplicate primary key problem.
The behaviour in case 2 is ambiguous to me...I was expecting the records to be
inserted as 1,11,21,31.....
Can anyone please clarify ??
Thanks
-Rais
"Rais" <[email protected]> wrote:
>
Hi Rob,
The weblogic Docs and the DTD says that "key-cache-size" should be equal
to the
INCREMENT VALUE of the Sequence in DB.Lemme point out what I have interpreted
from that.Please correct me if I am wrong.
lets say my sequence is
CREATE SEQUENCE TEMP_SEQ INCREMENT BY 2.
And my key-cache-size value is also 2.
I believe that by keeping these two values equal,records would be inserted
into
the DB as 1,3,5,7......
But in a clustered environment,each CMP would still be hitting the DB
to get the
sequence number.
What I mean to say is key-cache-size is actually not meant for caching
the sequence
numbers.
Even if it is ,how would the servers in the cluster maintain the same
state of
their individual cache same ??
Regards
-Rais
Rob Woollen <[email protected]> wrote:
Did you set a key-cache-size in your CMP deployment descriptor?
-- Rob
Rais wrote:
Hi All,
In WL6.1, one can mention the name of the sequence and the DB in thecmp-rdbms-jar.xml
to use the sequence generated number to use as a primary key.
Though my work is being done by the WL server but still WL server
is
hitting the
DB for each insert.
There are a couple of discussions listed on theserverside.com, butmost of them
fail for a clustered environment.
Can anyone please suggest me a solution where the WL server would
cache
the keys
instead of hitting the DB for each insert ?
Thanks in advance for your help !!
Regards
-Rais

Similar Messages

  • JBoss Clustering | Issue with sequence generator

    Hi all,
    I am facing a strange issue. I have 2 instances of jboss on the same machine and we have a number of stateless session beans used in our application. Now, I have written a Stateless session bean for sequence generator. I am able to run it on one instance but it is failing on another instance (even if I am only this running this one instance).
    It gives the following error:
    com.proximities.common.utils.SequenceIdGeneratorUtil: Method: getSequence(): Message: TableKey : VENUE
    2005-08-02 11:19:58,406 DEBUG [com.proximities] Class: utils.SequenceIdGeneratorUtil: Method: getSequence(): Message: Fetching from sequence proxy factory: VENUE
    2005-08-02 11:19:58,406 DEBUG [com.proximities] Class: ejb.EJBLookupUtil: Method: getInitialContext: Message: Using JNDI initial context: org.jnp.interfaces.NamingContextFactory
    2005-08-02 11:19:58,406 DEBUG [com.proximities] Class: ejb.EJBLookupUtil: Method: getInitialContext: Message: Using JNDI URL: jnp://localhost:11099
    2005-08-02 11:19:58,406 DEBUG [com.proximities] Class: ejb.EJBLookupUtil: Method: getInitialContext: Message: Using JNDI initial context prefix: org.jboss.naming:org.jnp.interfaces
    2005-08-02 11:19:58,421 DEBUG [com.proximities] Class: ejb.EJBLookupUtil: Method: getSequenceFacade: Message: SequenceStoreFacadeHome - Sequence store facade home returned from ejbHomeFactory isnull
    2005-08-02 11:19:58,421 FATAL [com.proximities] Class: ejb.EJBLookupUtil: Method: getSequenceFacade: Message: Exception during the invoking the remote interface
    2005-08-02 11:19:58,421 INFO [STDOUT] java.lang.NullPointerException
    2005-08-02 11:19:58,421 INFO [STDOUT] ejb.EJBLookupUtil.getSequenceFacade(Unknown Source)
    2005-08-02 11:19:58,421 INFO [STDOUT] sequence.SequenceProxyFactory.getSequenceStore(Unknown Source)
    2005-08-02 11:19:58,421 INFO [STDOUT] sequence.SequenceProxyFactory.reserveBlock(Unknown Source)
    2005-08-02 11:19:58,421 INFO [STDOUT] sequence.SequenceProxyFactory.<init>(Unknown Source)
    2005-08-02 11:19:58,421 INFO [STDOUT] sequence.SequenceProxyFactory.getSequence(Unknown Source)
    2005-08-02 11:19:58,421 INFO [STDOUT] at common.utils.SequenceIdGeneratorUtil.getSequence(Unknown Source)
    2005-08-02 11:19:58,421 INFO [STDOUT] at dataaccess.VenueDAO.add(Unknown Source)
    2005-08-02 11:19:58,421 INFO [STDOUT] at dataaccess.VenueDAO.update(Unknown Source)
    2005-08-02 11:19:58,421 INFO [STDOUT] at dataaccess.common.GenericDataAccessManager.executeModify(Unknown Source)
    2005-08-02 11:19:58,421 INFO [STDOUT] at business.mediator.ManageVenueMediator.insertIntoVenues(Unknown Source)
    2005-08-02 11:19:58,421 INFO [STDOUT] at business.sessionfacade.VenueManagementFacadeEJBean.insertIntoVenues(Unknown Source)
    2005-08-02 11:19:58,421 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2005-08-02 11:19:58,421 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    2005-08-02 11:19:58,421 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    2005-08-02 11:19:58,421 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:130)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.ejb.plugins.CleanShutdownInterceptor.invoke(CleanShutdownInterceptor.java:264)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.ejb.Container.invoke(Container.java:873)
    2005-08-02 11:19:58,421 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2005-08-02 11:19:58,421 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    2005-08-02 11:19:58,421 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    2005-08-02 11:19:58,421 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:155)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:104)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:179)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:165)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:97)
    2005-08-02 11:19:58,421 INFO [STDOUT] at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86)
    2005-08-02 11:19:58,421 INFO [STDOUT] at $Proxy92.insertIntoVenues(Unknown Source)
    Now within the server logs, I can see that it has loaded and cached the home interface of that bean, but dont know why its not picking it up.
    Here are the logs for the same:
    [org.jboss.ejb.EjbModule] startService, starting container: SequenceStoreFacade
    [org.jboss.system.ServiceController] starting service jboss.j2ee:jndiName=ejb.SequenceStoreFacadeHome,service=EJB
    [org.jboss.ejb.StatelessSessionContainer] Starting jboss.j2ee:jndiName=ejb.SequenceStoreFacadeHome,service=EJB
    [org.jboss.ejb.StatelessSessionContainer] Begin java:comp/env for EJB: SequenceStoreFacade
    [org.jboss.ejb.StatelessSessionContainer] TCL: org.jboss.util.loading.DelegatingClassLoader@188d92e
    [org.jboss.ejb.StatelessSessionContainer] Bound java:comp/ORB for EJB: SequenceStoreFacade
    [org.jboss.ejb.StatelessSessionContainer] Bound java:comp:/HandleDelegate for EJB: SequenceStoreFacade
    [org.jboss.ejb.StatelessSessionContainer] End java:comp/env for EJB: SequenceStoreFacade
    [org.jboss.ejb.plugins.local.BaseLocalProxyFactory] SequenceStoreFacade cannot be Bound, doesn't have local and local home interfaces
    [org.jboss.proxy.ejb.ProxyFactory] (re-)Binding Home ejb.SequenceStoreFacadeHome
    [org.jboss.proxy.ejb.ProxyFactory] Bound SequenceStoreFacade to ejb.SequenceStoreFacadeHome
    [org.jboss.system.ServiceController] starting service jboss.j2ee:service=EJB,plugin=pool,jndiName=ejb.SequenceStoreFacadeHome
    [org.jboss.ejb.plugins.StatelessSessionInstancePool] Starting jboss.j2ee:service=EJB,plugin=pool,jndiName=ejb.SequenceStoreFacadeHome
    [org.jboss.ejb.plugins.StatelessSessionInstancePool] Started jboss.j2ee:service=EJB,plugin=pool,jndiName=ejb.SequenceStoreFacadeHome
    [org.jboss.system.ServiceController] Starting dependent components for: jboss.j2ee:service=EJB,plugin=pool,jndiName=ejb.SequenceStoreFacadeHome dependent components: []
    [org.jboss.resource.connectionmanager.CachedConnectionInterceptor] start called in CachedConnectionInterceptor
    [org.jboss.ejb.StatelessSessionContainer] Started jboss.j2ee:jndiName=ejb.SequenceStoreFacadeHome,service=EJB
    [org.jboss.system.ServiceController] Starting dependent components for: jboss.j2ee:jndiName=ejb.SequenceStoreFacadeHome,service=EJB dependent components: []
    BTW, I am using JCS for caching and JBoss 4.0. Any pointers will be most appreciated?
    Thanks,
    Vikrant Verma

    You'll get a lot more help with this by posting this to the JBoss forums. This forum is about the J2EE SDK which uses the Sun Java System Application Server.
    -Ian Evans

  • JPA: Oracle Sequence Generator not up to date

    Hi,
    I'm using the JPA Oracle Sequence Generator in one of my JPA classes:
    @Entity
    @Table(name = "DACC_COST_TYPE")
    public class JPACostType implements Serializable {
    @SequenceGenerator(name = "CostTypeGenerator", sequenceName = "DACC_COST_TYPE_SEQ")
        @Column(name = "ID_COST_TYPE")
        @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CostTypeGenerator")
        private Integer idCostType;
    In order to persist a new object I perform the following code:
    @PersistenceContext
    private EntityManager em;
    JPACostType myJPA = new JPACostType();
    myJPA.setIdCostType = null;
    em.merge(myJPA);
    em.flush();
    Normally this works fine. But after deploying the app there sometimes happens an error:
    Caused by: javax.persistence.PersistenceException: SQLException while inserting entity {com.karmann.dacc.ejb.busilog.jpa.JPACostType(idCostType=4)}.
    at com.sap.engine.services.orpersistence.core.PersistenceContextImpl.flush(PersistenceContextImpl.java:278)
    at com.sap.engine.services.orpersistence.core.PersistenceContextImpl.beforeCompletion(PersistenceContextImpl.java:565)
    at com.sap.engine.services.orpersistence.entitymanager.EntityManagerImpl.beforeCompletion(EntityManagerImpl.java:410)
    at com.sap.engine.services.orpersistence.environment.AppJTAEnvironmentManager.beforeCompletion(AppJTAEnvironmentManager.java:197)
    at com.sap.engine.services.ts.jta.impl.TransactionImpl.commit(TransactionImpl.java:232)
    ... 52 more
    Caused by: java.sql.SQLException: ORA-00001: unique constraint (AEMA.DACC_COST_TYPE_PK) violated
    Obviously JPA does not fetch the new key by accessing the Oracle sequence. This documents "next value = 5". Does JPA fetch the new key from its cache? Is there any possibility to avoid this?
    Thanks for each hint,
    Christoph

    Hello Christoph Schäfer  ,
    I am stuck with a similar issue. I was able to save mutiple entries and there has not been much change to my JPA. I added new entities and new sequences.
    Now, I get the error Caused by: javax.persistence.PersistenceException: java.sql.SQLException: ORA-02289: Sequence ist nicht vorhanden.
    I have checked the name of sequence and sequence next val on the DB. It works on DB but when i execute it from ejb, it gives me thsi error. Now, it gives the error for all previously working JPA entities.
    I have also provided allocationSize = 1 for all entities.
    Please let me know, possible cause/solution to this issue.
    thank you.
    Regards,
    Sharath

  • Max-beans-in-cache ==== Error

    Hi all,
    I have a entity bean with max-beans-in-cache=5000 and one of the findByXXX fetches
    more than that and the application stops with an exception. Is there anyway or
    a strategy to follow when cases like this where the records of find exceeds the
    max limit. This is a huge data process application and we tried to do maximum
    filters to reduce the records to minimal.
    Please help me with your thoughts or ideas to .. how to avoid or is there any
    deployment time argument .. etc
    using WL 7.0
    Thanks
    -arun

    If you just invoke the finder, then the container should not complain
    about bringing back > max-beans-in-cache elements. However if you try
    to enlist > max-beans-in-cache beans in a transaction, it will throw a
    CacheFull.
    One way to avoid this is to limit your maxRows returned by the finder.
    This can be done in the CMP descriptor.
    -- Rob
    Arun nair wrote:
    Hi all,
    I have a entity bean with max-beans-in-cache=5000 and one of the findByXXX fetches
    more than that and the application stops with an exception. Is there anyway or
    a strategy to follow when cases like this where the records of find exceeds the
    max limit. This is a huge data process application and we tried to do maximum
    filters to reduce the records to minimal.
    Please help me with your thoughts or ideas to .. how to avoid or is there any
    deployment time argument .. etc
    using WL 7.0
    Thanks
    -arun

  • Issues with Sequence Generator

    I'm having trouble with Sequence generator not generating continuous numbers starting from 1, each time I run the mapping.
    I want the Sequence to start from 1, each time the mapping is run. For this to happen, I'm using a pre-mapping operator which uses an oracle procedure to reset the sequence.
    But, the sequence generates the numbers from some weird number, say 3508 and then jumps to 5006 and so on. I'm not able to track what's wrong with the sequence. I have stopped the caching in Sequence but still it hasn't helped. I'm sure and have verified that the procedure being used to reset the sequence is running fine.
    Please suggest some additional parameters/properties at OWB level to be checked for the sequence, if any OR any thoughts on why the sequence is not starting from 1. Thanks in advance.
    Thanks,
    Sachin
    Edited by: 850549 on Apr 23, 2011 11:43 AM
    Edited by: 850549 on Apr 23, 2011 11:44 AM

    Could you check whether the sequence you use has a cache value greater than 1 defined in the database. This way if your database regularly should be stoped, e.g for offline backup, you'll loose the sequence values that were unused in memory at that time. That way the gaps in your surrogate ids would be explainable.

  • Could this Fibonacci sequence generator and prime tester code be made more

    Hey,
    Could this Fibonacci sequence generator and prime tester code be made more efficient?
    package sideprojects;
    public class Exam2008Question2F
         public static boolean isPrime(int n)
              int div=2;
              while(div*div<=n)
                   if(n%div==0)
                        return(false);
                   div++;
              return true;
         public static void main (String [] args)
              int prev = 1, curr = 1;
              System.out.println(prev+": It's a prime number.");
              for(int i=0;i<10;i++)
                   if(isPrime(curr))
                        System.out.println(curr + ": It's a prime number.");
                   else
                        System.out.println(curr + ": It's not a prime number.");
                   int next = prev + curr;
                   prev = curr;
                   curr = next;
    1: It's a prime number.
    1: It's a prime number.
    2: It's a prime number.
    3: It's a prime number.
    5: It's a prime number.
    8: It's not a prime number.
    13: It's a prime number.
    21: It's not a prime number.
    34: It's not a prime number.
    55: It's not a prime number.
    89: It's a prime number.Edited by: woodie_woodpeck on Apr 26, 2009 3:42 AM

    corlettk wrote:
    Not what you expected? Or are you saying something about the performance of long arithmetic verses int?No, I thought you posted your method using long's as well. When you implement them both using int's (or long's), the 6-increment should run quicker:
    public class PrimeTester {
        public static boolean isPrimeInc2(long n) {
            if(n < 2) return false;
            if(n == 2) return true;
            if(n%2 == 0) return false;
            long sqrtN = 1+(long)Math.sqrt(n);
            for(long i = 3; i <= sqrtN; i += 2) {
                if(n%i == 0) return false;
            return true;
        public static boolean isPrimeInc6(long n) {
            if(n < 2) return false;
            if(n == 2 || n == 3) return true;
            if(n%2 == 0 || n%3 == 0) return false;
            long sqrtN = 1+(long)Math.sqrt(n);
            for(long i = 6L; i <= sqrtN; i += 6) {
                if(n%(i-1) == 0 || n%(i+1) == 0) return false;
            return true;
        public static boolean isPrimeCached(long n) {
            if(n == 2) return true;
            if(n < 2) return false;
            long[] cache = {2,3,5,7,11,13,17,19,23,29,31};
            for(long c : cache) {
                if(n == c) return true;
                if(n%c == 0) return false;
            long stop = (long)Math.sqrt(n);
            for(long i = cache[cache.length-1]; i <= stop; i += 2) {
                if(n%i == 0) return false;
            return true;
        public static void main(String[] args) {
            long N = 1000000, start = 0, end = 0, repeat = 5;
            while(repeat-- > 0) {
                start = System.currentTimeMillis();
                for(long i = 1; i <= N; i++) isPrimeInc2(i);
                end = System.currentTimeMillis();
                System.out.println("isPrimeInc2(...) upto "+N+" took "+(end-start)+" ms.");
                start = System.currentTimeMillis();
                for(long i = 1; i <= N; i++) isPrimeInc6(i);
                end = System.currentTimeMillis();
                System.out.println("isPrimeInc6(...) upto "+N+" took "+(end-start)+" ms.");
                start = System.currentTimeMillis();
                for(long i = 1; i <= N; i++) isPrimeCached(i);
                end = System.currentTimeMillis();
                System.out.println("isPrimeCached(...) upto "+N+" took "+(end-start)+" ms.\n");
    }

  • Is it possible to map the cmp fields of the entity bean with out dictionary

    Dear sirs,
    I have created the EJB project module and WEB Module. Now i have to map the CMP fields of the entity bean to the underlying table. Is it possible to map the cmp fields of the entity bean with out java dictionary? If yes how can we do that.
    I have got some error while mapping an EJB's CMP fields to the table through dictionary. I was actually intended to map 79 fields but it gives an error that more than 64 fields are not allowed while building the dictionary.
    1. Can you tell me what could be the possible reason?
    2. Is it possible to map the cmp fields of the entity bean with out java dictionary? If yes how can we do that.
    Kindly helo me,
    Sudheesh K S

    Hi,
    Sudheesh please check up if the below link helps,there are other ways of writing the persistent.xml for container managed entity bean.
    http://help.sap.com/saphelp_nw04s/helpdata/en/9b/f695f0c84acf46a4e0b31f69d8a9b7/frameset.htm, probably in the studio you cannot browse through tables not in  the java dictionary,but manually editing it may still solve the problem.
    Also here is another link that specifies the databases supported by J2EE Engine.
    http://help.sap.com/saphelp_nw04s/helpdata/en/66/a5283eeb47b40be10000000a114084/frameset.htm
    The below link shows how to specify the database vendor and datasource
    http://help.sap.com/saphelp_nw04s/helpdata/en/e1/67fc3ee241ba28e10000000a114084/frameset.htm
    Hope you are able to solve the problem.
    Do let us know if you come up with the solution.
    Regards,
    Harish
    Message was edited by: HARISH SUBRAMANIAN

  • Java persistence: sequence generator not working in expected way.

    Hi,
    I just played around with java persistence api and found that sequence generator annotations for making new primary key value not working correctly in my code. following is part of my code related to this problem.
    in entity class:
    @SequenceGenerator(name="mySeq", sequenceName="MY_SEQ_IN_DB")
    @Id
    @GeneratedValue(strategy=SEQUENCE, generator="mySeq")
    @Column(name = "UPLOAD_ID", nullable = false)
    private Integer uploadId;
    I have a sequence called MY_SEQ_IN_DB in my oracle 9i testing db. When I ran the code to save a new entity instance to database I found that the new upload id is not the one that should be created from the MY_SEQ_IN_DB sequence, while the sequence was not increased either. It's instead something starting from 97 (in my pc), and increased just like a sequence, but every time I reran my code the sequence restarted itself again beginning with 97(of course the insert failed with primary key conflict). the behavior just looks like it's a sequence created and managed totally by the persistence api or toplink itself (I guess).
    So, my question is, is this a designed behavior or have I done something wrong to make it not using the correct sequence in the db?
    I used hibernate before, and assigning new primary key from sequence in this way works fine.
    Thanks
    JC.L

    There are some things in Java which can't be serialized. When contained within a higher-level class such as Buttons. A button can be associated with an Action Listener. Now, you can serialize a button; however you can't serialize an action listener - for what should be to you obvious reasons. This is NOT an error and so there is no need to throw an exception when serializing the button.
    Basically: Applet sends servlet button, but not listener.

  • Max Beans in Cache causes NULL Pointer Exception

    Hi All,
    a rather weird event (from our perspective) occurs when we do the
    following:
    We have an entity bean set to max beans in cache 100 (default value of
    our deployment tool ), the database table related to that bean holds
    lets say 300 entries.
    Doing a find all and in the same session bean instanciated transaction a
    processing loop over the enumeration of beans we get an NULL Pointer
    exception when accesing the 101 Bean. Neverthless the Weblogic server
    increases the cache size automatically but obviously not fast enough and
    not on time.
    has anyone experienced the same problem and has a fix for it, appart
    from increasing the cache size in the deployment descriptor ?
    any help welcome
    Michael

    Hi Michael.
    Can you post the stack trace of the NullPointerException? Was it in
    your code or ours? Also, what version of WebLogic are you using?
    -- Rob
    Rob Woollen
    Software Engineer
    BEA WebLogic
    [email protected]
    Michael Rupprecht wrote:
    Hi All,
    a rather weird event (from our perspective) occurs when we do the
    following:
    We have an entity bean set to max beans in cache 100 (default value of
    our deployment tool ), the database table related to that bean holds
    lets say 300 entries.
    Doing a find all and in the same session bean instanciated transaction a
    processing loop over the enumeration of beans we get an NULL Pointer
    exception when accesing the 101 Bean. Neverthless the Weblogic server
    increases the cache size automatically but obviously not fast enough and
    not on time.
    has anyone experienced the same problem and has a fix for it, appart
    from increasing the cache size in the deployment descriptor ?
    any help welcome
    Michael

  • Clarification on the limitation of sequence generator in T-SQL

    Hi, I found this limitation of sequence numbers for T-SQL:
    "If there are multiple instances of the NEXT
    VALUE FOR function specifying the same sequence generator within a single Transact-SQL statement, all those instances
    return the same value for a given row processed by that Transact-SQL statement. This behavior is consistent with the ANSI standard."
    From this link:  http://technet.microsoft.com/en-us/library/ff878058.aspx
    Does this mean that if we want to have different value generated then we can't use it in multi-threading environment whereby multiple instances / processes are calling the same T-SQL code that generate the sequence numbers using the
    NEXT VALUE FOR function?
    My understanding of the above might not be correct, any sample example to illustrate this limitation? 
    Thanks

    Hi
    This is the meaning of the comment in the article.
    If you are using in a single t-sql
    statement several times (NEXT VALUE FOR) then it will act as you use the same value. This is in-design :-)
    try this for example:
    select (NEXT VALUE FOR MySequenceName),(NEXT VALUE FOR MySequenceName),(NEXT VALUE FOR MySequenceName) -- same value several times
    But you can use (NEXT VALUE FOR) several time like this:
    DECLARE @QQ_01 int, @QQ_02 int, @QQ_03 int, @QQ_04 int
    SET @QQ_01 = NEXT VALUE FOR MySequenceName;
    SET @QQ_02 = NEXT VALUE FOR MySequenceName;
    SET @QQ_03 = NEXT VALUE FOR MySequenceName;
    SET @QQ_04 = NEXT VALUE FOR MySequenceName;
    SELECT @QQ_01,@QQ_02,@QQ_03,@QQ_04 -- different valus
    Hope this clarify things :-)
    [Personal Site] [Blog] [Facebook]

  • How to set a sequence generator as a value

    When i am creating a new object in a table there is a unique id i want to keep to identify this object and I use sequence generator. I believe the command is DB_SEQ_PK.NEXTVAL, do i put this statement as a "SQL EXP" in the Source value for the specific variable i want to set it to? Please give me the right expression if i am wrong thank you.

    Raj,
    i tested it with the emp table the following way:
    Extend This Application
    A page or application component
    Component > Form > Table
    [selected EMP table, page 40, the rest default]
    Edit Page 40
    Edit Page Item P40_EMPNO
    Alternate source used: Only when current value is session state is null
    Source Type: SQL Query
    Source value or expression: SELECT CT_ID_SEQ.NEXTVAL FROM DUAL;
    Apply Changes
    Run Page
    [The empno field shows a value of 50]
    [I enter 'test' into the ename field and click 'Create']
    [I receive the error: ORA-01400: cannot insert NULL into ("EAS"."EMP"."EMPNO")]
    I'm not sure what i am doing wrong here.
    Thanks

  • Sequence Generator problem in OWB Mapping

    Hi,
    I am using a Sequence Generator in my Dimension mapping. And OWB implements the mapping via an Oracle MERGE statement.
    However when I execute the mapping my sequence number value gets incremented even when there are only updates and no inserts taking place during the execution.
    I am using the sequence number only for inserts and not for updates in the mapping.
    Is there a way to avoid this situation or a work around to this problem? This is very urgent and any help in this area would be greatly appreciated.
    Thanks

    Hi
    I also have the same problem as I loose the seq numbers when there are updates only and I do not want to loose thousands of seq numbers. I tried with bulk size =1 as well as row based only execution but no result.
    The thing which solved this problem is to have outer join with source and target, then use splitter to find out new and updated records (by looking the join key as null on target table side), then use a fuction to generate seq number when the key is not null. But doing all this does not seem to be elegant performance point of you. I do not want to join source and target due to performance issues.
    Could you pl clrify your apprach. Are you using , Source minus target and Source Intersect Target . What you will do if there is no one to one matching between source and the target.
    Thanks

  • Max beans in cache

    Hi ,
    I have the following parameter set in weblogic-ejb-jar.xml for a statefulsession bean.
    ==================================================
    stateful-session-cache>
    <max-beans-in-cache>2</max-beans-in-cache>
    <idle-timeout-seconds>600</idle-timeout-seconds>
    </stateful-session-cache>
    ==================================================
    I then create more than 2 requests(approx 10) to the stateful session bean for which the above parameter is set.
    In EJB-MONITORING-Stateful Ejbs I have the following fields set from the customize view:
    Activation Count
    Passivation Count
    Cache Access Count
    Cache Miss Count
    Cached Beans Current Count
    EJB Name
    My understanding is that no more than 2 beans should appear in the Cached Beans Current Count.If the request is sent from more than 2 browsers invoking the stateful bean I should get Invocation Target exception.
    But upon sending requests from more than 2 browsers invoking the same session bean I see that :
    count of Cached Beans Current Count = number of browsers/clients from where the request is coming.
    There is no exception.
    Kindly clarify my understanding.
    Thanks

    Hi,
    if you give some number in <max-beans-in-cache>number</max-beans-in-cache>.Then Weblogic Server going to create that many number of objects initially .
    In case of statefull SessionBeans, If you give 3 ,Then Server creates 3 objects for that bean to provide service to the 3 clients at a time .
    Whenever it receives the 4 requests at a time then three request's will be served at a time and 4th request will wait until the server passivate any object out of 3 in some persistant storage and create the object for 4th client.
    it will not throw any exception or error if we sent more than number of requests which we were mention in max-beans-in-cache.
    ----Anilkumar kari

  • Max-beans-in-cache, cachefullException, outOfMemoryError

    Hi,
    I am trying to find the best way to find the numbers to be set in max-beans-in-cache
    for entity beans. I have a stateless session bean through which I access the entity
    beans. If I don't set any value for this property, in some query which will return
    2500 records, I get a cachefullexception and if I increase it and set this property
    to say 5000, I get an outofmemory error. I am not sure how to decide what value
    should be used. Any help or suggestion would be greatly appreciated. We are using
    WLS 7.0 on NT machines in a cluster.
    I have already tried the maxPermSize option in the jvm. The max heap size is
    set to 768m.
    Thanks,
    Jaideep

    Please reply only to the newsgroup.
    If you are doing a find and then invoking on the bean, splitting the transaction into
    multiple transactions that return smaller sets of beans is the only thing I can think of to
    get around the problem.
    If you are simply doing a find, but not invoking the beans, you could set finders-load-bean
    to false in the EJB deployment descriptor to avoid loading the bean when the finder is
    called. The bean will then be loaded and put into the cache only when it is invoked.
    However, this setting affects all finders defined on the bean and if you have transactions
    that do a find and invoke, performance could be lower if set to false.
    Unless relationship-caching is turned on, related beans are not loaded when a finder is
    invoked.
    Arunabh
    "Chadha, Jaideep" wrote:
    Thanks Arunabh. I tried different values and came
    up with the ones that suite our needs. Also the
    cache size is restricted in a transaction, we can
    split the transactions into multiple transactions
    especially for read-only data. Do you think that
    would be a good idea? I was also thinking if it
    was possible to define the attribute for the
    entity beans especially in case of relationships that
    they get loaded in finders when I need them but for
    some methods they don't get loaded in finders. And
    when a getXXX is invoked that particular bean gets
    loaded at that time.
    It will be helpful, if you could let me know.
    Thanks,
    JaideepArunabh Hazarika wrote:
    Increasing the max-beans-in-cache will always mean higher memory requirements. Afraid
    there is no way around it except to increase the max heap size. You could try a new
    feature in WLS 7.0 - application level caches. This is specified in the application
    deployment descriptor rather than at the bean deployment descriptor. With this cache,
    the cache size can be specified in terms of memory-size rather than an instance-count.
    You can find out how to set this from:
    http://e-docs.bea.com/wls/docs70/programming/app_xml.html (search for entity-cache)
    This cache would be shared across all EJBs in the application. Also, note that this will
    not prevent CacheFullExceptions from occuring, but would be more useful in avoiding
    OutOfMemory errors. To avoid CacheFullExceptions without indefinitely increasing the
    heap size, try to limit the number of beans loaded in a single transaction.
    Hope this helps
    Arunabh
    Jaideep wrote:
    Hi,
    I am trying to find the best way to find the numbers to be set in max-beans-in-cache
    for entity beans. I have a stateless session bean through which I access the entity
    beans. If I don't set any value for this property, in some query which will return
    2500 records, I get a cachefullexception and if I increase it and set this property
    to say 5000, I get an outofmemory error. I am not sure how to decide what value
    should be used. Any help or suggestion would be greatly appreciated. We are using
    WLS 7.0 on NT machines in a cluster.
    I have already tried the maxPermSize option in the jvm. The max heap size is
    set to 768m.
    Thanks,
    Jaideep

  • Are EJB ( entity beans) are cached ?

    Are EJB ( entity beans) are cached ?
    I have a doubt here . As per my understanding , the entity beans are cached from the database. In that case , If I delete a row in the database by an external application ( say using TOAD tool) , how the Entity bean will be updated / reloaded ? Entity bean will be out of sync then .
    Application server : weblogic/webspehere .

    >
    You can use the refresh method of the EntityManager interface to read new values from the database (if you expect it to be out of sync), and use locks to prevent others from changing your data while the application is performing actions in a transaction.Did you mean I have to write code for this ? can't be made it automatic refresh by the container ? Is there any settings I can configure so that container can do it by itself proactively ?
    Also, using locks ...is this a container settings or I need to configure myself in ejb-jar.xml ? Could you please shed some light here ?

Maybe you are looking for

  • Alert tone variety

    Is there a way to set separate alert tones to differentiate between email/text and mere app notifications.......?

  • Word 2007 doesn't open any documents.

    Hello. Our team are running Outlook 2010 and all the other office apps in 2007. However, Word 2007 always has a problem with opening documents. It works, shows none of error messages and the Word 2007 window opens properly but just doesn't show any d

  • IMOVIE copies to DVD disk

    I see where you can publish to YouTube, Iphone, etc. I do not see where you can just copy to a DVD disk as a backup. Any help?

  • ALV Tree - Excel & header comment

    Hello, I want to export to excel my ALV tree. I'm using the FM 'ALV_XXL_CALL'.  But I would like to set the header comment from the ALV in the excel sheet (before the data). How I have to do ? Thank you Bernard Pochin.

  • How to use JEditorPanel to display an HTML page from a String?

    Hi, I need to store a report in HTML format which is store in String and when I use JEditorPane.setText to insert the string and JeditorPane refused to display and content or just the String "<HTML> <HEAD>..." in plain text. SHould I use other method