Announcement Announcement Module
Collapse
No announcement yet.
Integration Tests fail Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Integration Tests fail

    Hi,

    I am new to Spring Roo. I have created a project using this tool. My project has two domain objects: Person and Address. Person has a reference to Address. When I use Mysql and Hibernate, all my integration tests fail . But if I change database from mysql to hypersonic-in-memory all integration tests are ok (i mean pass). Can anyone please explains me this is happenning ?

    Here is my integration test for Person:

    package com.foo.neoroo.domain;

    import java.util.Date;

    import javax.sql.DataSource;

    import junit.framework.Assert;

    import org.springframework.beans.factory.annotation.Autow ired;
    import org.springframework.jdbc.core.simple.SimpleJdbcTem plate;
    import org.springframework.roo.addon.test.RooIntegrationT est;
    import com.foo.neoroo.domain.Person;
    import org.junit.Test;

    @RooIntegrationTest(entity = Person.class)
    public class PersonIntegrationTest {

    private SimpleJdbcTemplate jdbcTemplate;

    @Autowired
    public void initializePersonIntegrationTest(DataSource ds){
    jdbcTemplate = new SimpleJdbcTemplate(ds);
    }

    @Test
    public void testMarkerMethod() {

    int count = jdbcTemplate.queryForInt("select count(0) from Person");

    Person person = new Person();
    person.setFirstName("Sanjoy");
    person.setLastName("Roy");
    person.setDateCreated(new Date());
    person.setDateUpdated(new Date());

    person.persist();

    count = jdbcTemplate.queryForInt("select count(0) from Person");

    Assert.assertEquals(1, count);

    System.out.println(person);
    }
    }


    Integration Test for Address


    package com.foo.neoroo.domain;

    import javax.sql.DataSource;

    import junit.framework.Assert;

    import org.springframework.beans.factory.annotation.Autow ired;
    import org.springframework.jdbc.core.simple.SimpleJdbcTem plate;
    import org.springframework.roo.addon.test.RooIntegrationT est;
    import com.foo.neoroo.domain.Address;
    import org.junit.Test;

    @RooIntegrationTest(entity = Address.class)
    public class AddressIntegrationTest {

    private SimpleJdbcTemplate jdbcTemplate;

    @Autowired
    public void initializeAddressIntegrationTest(DataSource ds){
    jdbcTemplate = new SimpleJdbcTemplate(ds);
    }

    @Test
    public void testMarkerMethod() {

    int count = jdbcTemplate.queryForInt("select count(0) from Address");

    Address address = new Address();
    address.setHouseNo("70");
    address.setPostcode("sd2 3ds");
    address.persist();

    System.out.println(address);

    int count1 = jdbcTemplate.queryForInt("select count(0) from Address");

    System.out.println(address);

    Assert.assertEquals(1, count1);

    }
    }


    Thanks in advance.

    Cheers
    Sanjoy

  • #2
    Have you created the database as InnoDB in MySQL? Hibernate won't do that as set up by Roo even if the user referred to in database.properties have the proper permissons to create databases. Possibly you'll need to give the user the proper permissions in the database you set up too, but if the user is an admin it might work anyway .
    Last edited by MiB; Dec 30th, 2010, 02:38 PM.

    Comment


    • #3
      Thank you for your reply. I have created the database manually. I have checked all the tables. They all have innodb storage engine. I have granted all permissions to the database user that I have used in database.properties file. But still same problem.

      Comment


      • #4
        Can you supply us with the stack traces? If you're new to Maven, they'd be in target/surefire-reports. It could still be a configuration problem. I know that I had to actually configure my MySQL to use InnoDB by default, or the tests failed.

        Can you write a small piece of MySQL database script to begin a tran, do two updates, then try to issue a rollback, just to make 100% sure that the transaction engine is working properly?

        Here is a blog post I did a while back on troubleshooting InnoDB on MySQL. I am on a mac, so a few things would be different if you are on windows, but otherwise the concepts are the same.

        http://www.rimple.com/tech/2010/8/29...ot-be-you.html


        Ken

        Comment


        • #5
          Hi,

          Here is the surefire-report of one of the Integration test

          -------------------------------------------------------------------------------
          Test set: com.foo.neoroo.domain.PersonIntegrationTest
          -------------------------------------------------------------------------------
          Tests run: 9, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.537 sec <<< FAILURE!
          testMarkerMethod(com.foo.neoroo.domain.PersonInteg rationTest) Time elapsed: 0.048 sec <<< FAILURE!
          junit.framework.AssertionFailedError: expected:<1> but was:<0>
          at junit.framework.Assert.fail(Assert.java:47)
          at junit.framework.Assert.failNotEquals(Assert.java:2 83)
          at junit.framework.Assert.assertEquals(Assert.java:64 )
          at junit.framework.Assert.assertEquals(Assert.java:19 5)
          at junit.framework.Assert.assertEquals(Assert.java:20 1)
          at com.foo.neoroo.domain.PersonIntegrationTest.testMa rkerMethod(PersonIntegrationTest.java:42)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.junit.runners.model.FrameworkMethod$1.runRefle ctiveCall(FrameworkMethod.java:44)
          at org.junit.internal.runners.model.ReflectiveCallabl e.run(ReflectiveCallable.java:15)
          at org.junit.runners.model.FrameworkMethod.invokeExpl osively(FrameworkMethod.java:41)
          at org.junit.internal.runners.statements.InvokeMethod .evaluate(InvokeMethod.java:20)
          at org.springframework.test.context.junit4.statements .RunBeforeTestMethodCallbacks.evaluate(RunBeforeTe stMethodCallbacks.java:74)
          at org.springframework.test.context.junit4.statements .RunAfterTestMethodCallbacks.evaluate(RunAfterTest MethodCallbacks.java:82)
          at org.springframework.test.context.junit4.statements .SpringRepeat.evaluate(SpringRepeat.java:72)
          at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.runChild(SpringJUnit4ClassRunner.jav a:240)
          at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:50)
          at org.junit.runners.ParentRunner$3.run(ParentRunner. java:193)
          at org.junit.runners.ParentRunner$1.schedule(ParentRu nner.java:52)
          at org.junit.runners.ParentRunner.runChildren(ParentR unner.java:191)
          at org.junit.runners.ParentRunner.access$000(ParentRu nner.java:42)
          at org.junit.runners.ParentRunner$2.evaluate(ParentRu nner.java:184)
          at org.springframework.test.context.junit4.statements .RunBeforeTestClassCallbacks.evaluate(RunBeforeTes tClassCallbacks.java:61)
          at org.springframework.test.context.junit4.statements .RunAfterTestClassCallbacks.evaluate(RunAfterTestC lassCallbacks.java:70)
          at org.junit.runners.ParentRunner.run(ParentRunner.ja va:236)
          at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.run(SpringJUnit4ClassRunner.java:180 )
          at org.apache.maven.surefire.junit4.JUnit4TestSet.exe cute(JUnit4TestSet.java:59)
          at org.apache.maven.surefire.suite.AbstractDirectoryT estSuite.executeTestSet(AbstractDirectoryTestSuite .java:115)
          at org.apache.maven.surefire.suite.AbstractDirectoryT estSuite.execute(AbstractDirectoryTestSuite.java:1 02)
          at org.apache.maven.surefire.Surefire.run(Surefire.ja va:180)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.apache.maven.surefire.booter.SurefireBooter.ru nSuitesInProcess(SurefireBooter.java:350)
          at org.apache.maven.surefire.booter.SurefireBooter.ma in(SurefireBooter.java:1021)

          ---------------------------------------------------------
          Here is the stack trace


          2010-12-31 13:39:41,133 [main] DEBUG org.springframework.jdbc.datasource.DataSourceUtil s - Fetching JDBC Connection from DataSource
          2010-12-31 13:39:41,164 [main] DEBUG org.springframework.jdbc.datasource.DataSourceUtil s - Registering transaction synchronization for JDBC Connection
          2010-12-31 13:39:41,237 [main] TRACE org.hibernate.type.LongType - binding null to parameter: 1
          2010-12-31 13:39:41,241 [main] TRACE org.hibernate.type.TimestampType - binding '2010-12-31 13:39:41' to parameter: 2
          2010-12-31 13:39:41,250 [main] TRACE org.hibernate.type.TimestampType - binding '2010-12-31 13:39:41' to parameter: 3
          2010-12-31 13:39:41,250 [main] TRACE org.hibernate.type.StringType - binding 'Onjon' to parameter: 4
          2010-12-31 13:39:41,250 [main] TRACE org.hibernate.type.StringType - binding 'Shah' to parameter: 5
          2010-12-31 13:39:41,250 [main] TRACE org.hibernate.type.IntegerType - binding '0' to parameter: 6
          2010-12-31 13:39:41,263 [main] DEBUG org.springframework.jdbc.datasource.DataSourceUtil s - Returning JDBC Connection to DataSource

          ---------------------------
          All my tables are using InnoDB storage engine

          but still same problem.

          Comment


          • #6
            Hi,

            There is a update.

            When I have changed from the below lines:

            ------------------------------------------------------
            int count = jdbcTemplate.queryForInt("select count(0) from Person");
            Assert.assertEquals(1, count);
            ------------------------------------------------------

            to this line

            -----------------------------------------------------
            Assert.assertEquals(1, person.countPeople());
            -----------------------------------------------------

            my PersonIntegrationTest gets passed.

            I have found this countPeople() method from Person_Roo_Entity.aj

            public static long Person.countPeople() {
            return entityManager().createQuery("select count(o) from Person o", Long.class).getSingleResult();
            }


            Any idea.

            Comment


            • #7
              Ok, I think I see what is going on here.

              Are you trying to verify data that is saved in a method using Jdbc? If so, are you doing a entityManager.flush() before you do your Jdbc query?

              JPA / Hibernate use a session to cache all scheduled updates. Periodically, based on triggering events such as needing a server-side generated primary key for another entity's foreign key, or a commit, the context gets flushed automatically. That won't happen until those events happen, or you leave your transaction.

              If you do a flush, your jdbc query will likely work. However, querying through the session, using the JPA entity objects, is the right way to verify, since you are looking at the same session data that eventually gets flushed, so your view of the data is the same as JPA. Plus, you don't have to do a flush.

              Ken

              Comment


              • #8
                Hi,

                Thank you for your reply.

                I have put the below line before jdbc query

                Person.entityManager().flush();

                but unfortunately it does not work.

                Anyway as long as

                Assert.assertEquals(1, person.countPeople());

                works I am Ok.

                Comment


                • #10
                  Hi,
                  No, my test method does not have @Transactional annotation. But Person.persist() has @Transactional annotation. Anyway I have put the @Transactional annotation on my test method but it does not make any difference.

                  Comment


                  • #11
                    Drat, was worth a try

                    OK, at least you are approaching it the right way. I'm not sure what else could be happening. Last suggestion is to trace your SQL very carefully and see what is being outputted from Hibernate.

                    Anyway, Happy New Year!

                    Ken

                    Comment


                    • #12
                      Hi,
                      Thank you very much. Looking forward to see your book in Roo. It is a great RAD tool. Happy New Year.

                      Comment


                      • #13
                        Guys, I have similar question in Spring roo. I tried to create a entity using 'database reverse engineer' command and generated the test classes using 'test integration entity name'. Then I ran the 'perform tests' command and all my tests fails. I db configurations are for oracle using hibernate.

                        Please help me out if I am doing any thing wrong

                        -------------------------------------------------------------------------------
                        Test set: com.enets.db.NetPackageIntegrationTest
                        -------------------------------------------------------------------------------
                        Tests run: 7, Failures: 0, Errors: 7, Skipped: 0, Time elapsed: 22.186 sec <<< FAILURE!
                        testMarkerMethod(com.enets.db.NetPackageIntegratio nTest) Time elapsed: 4.733 sec <<< ERROR!
                        java.lang.IllegalStateException: Failed to load ApplicationContext
                        at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:308)
                        at org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener.injectDependencies (DependencyInjectionTestExecutionListener.java:109 )
                        at org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener.prepareTestInstanc e(DependencyInjectionTestExecutionListener.java:75 )
                        at org.springframework.test.context.TestContextManage r.prepareTestInstance(TestContextManager.java:321)
                        at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.createTest(SpringJUnit4ClassRunner.j ava:220)
                        at org.springframework.test.context.junit4.SpringJUni t4ClassRunner$1.runReflectiveCall(SpringJUnit4Clas sRunner.java:301)
                        at org.junit.internal.runners.model.ReflectiveCallabl e.run(ReflectiveCallable.java:15)
                        at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.methodBlock(SpringJUnit4ClassRunner. java:303)
                        at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.runChild(SpringJUnit4ClassRunner.jav a:240)
                        at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:50)
                        at org.junit.runners.ParentRunner$3.run(ParentRunner. java:193)
                        at org.junit.runners.ParentRunner$1.schedule(ParentRu nner.java:52)
                        at org.junit.runners.ParentRunner.runChildren(ParentR unner.java:191)
                        at org.junit.runners.ParentRunner.access$000(ParentRu nner.java:42)
                        at org.junit.runners.ParentRunner$2.evaluate(ParentRu nner.java:184)
                        at org.springframework.test.context.junit4.statements .RunBeforeTestClassCallbacks.evaluate(RunBeforeTes tClassCallbacks.java:61)
                        at org.springframework.test.context.junit4.statements .RunAfterTestClassCallbacks.evaluate(RunAfterTestC lassCallbacks.java:70)
                        at org.junit.runners.ParentRunner.run(ParentRunner.ja va:236)
                        at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.run(SpringJUnit4ClassRunner.java:180 )
                        at org.apache.maven.surefire.junit4.JUnit4TestSet.exe cute(JUnit4TestSet.java:59)
                        at org.apache.maven.surefire.suite.AbstractDirectoryT estSuite.executeTestSet(AbstractDirectoryTestSuite .java:115)
                        at org.apache.maven.surefire.suite.AbstractDirectoryT estSuite.execute(AbstractDirectoryTestSuite.java:1 02)
                        at org.apache.maven.surefire.Surefire.run(Surefire.ja va:180)
                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
                        at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
                        at java.lang.reflect.Method.invoke(Method.java:597)
                        at org.apache.maven.surefire.booter.SurefireBooter.ru nSuitesInProcess(SurefireBooter.java:350)
                        at org.apache.maven.surefire.booter.SurefireBooter.ma in(SurefireBooter.java:1021)
                        Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'transactionManager' defined in class path resource [META-INF/spring/applicationContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'entityManagerFactory' defined in class path resource [META-INF/spring/applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: netsDev] Unable to build EntityManagerFactory
                        at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:328)
                        at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:106)
                        at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1325)
                        at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1086)
                        at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:517)
                        at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
                        at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 91)
                        at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
                        at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:288 )
                        at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:190)
                        at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:580)
                        at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:895)
                        at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:425)
                        at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:84)
                        at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:1)
                        at org.springframework.test.context.TestContext.loadA pplicationContext(TestContext.java:280)
                        at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:304)
                        ... 28 more
                        Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'entityManagerFactory' defined in class path resource [META-INF/spring/applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: netsDev] Unable to build EntityManagerFactory
                        at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1420)
                        at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:519)
                        at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
                        at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 91)
                        at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
                        at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:288 )
                        at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:190)
                        at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:322)
                        ... 44 more
                        Caused by: javax.persistence.PersistenceException: [PersistenceUnit: netsDev] Unable to build EntityManagerFactory
                        at org.hibernate.ejb.Ejb3Configuration.buildEntityMan agerFactory(Ejb3Configuration.java:911)
                        at org.hibernate.ejb.HibernatePersistence.createConta inerEntityManagerFactory(HibernatePersistence.java :74)
                        at org.springframework.orm.jpa.LocalContainerEntityMa nagerFactoryBean.createNativeEntityManagerFactory( LocalContainerEntityManagerFactoryBean.java:225)
                        at org.springframework.orm.jpa.AbstractEntityManagerF actoryBean.afterPropertiesSet(AbstractEntityManage rFactoryBean.java:308)
                        at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1477)
                        at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1417)
                        ... 51 more
                        Caused by: org.hibernate.HibernateException: Wrong column type in schema.NET_PACKAGE for column NET_PACKAGE_ID. Found: char, expected: varchar2(255)
                        at org.hibernate.mapping.Table.validateColumns(Table. java:283)
                        at org.hibernate.cfg.Configuration.validateSchema(Con figuration.java:1313)
                        at org.hibernate.tool.hbm2ddl.SchemaValidator.validat e(SchemaValidator.java:139)
                        at org.hibernate.impl.SessionFactoryImpl.<init>(Sessi onFactoryImpl.java:376)
                        at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1842)
                        at org.hibernate.ejb.Ejb3Configuration.buildEntityMan agerFactory(Ejb3Configuration.java:902)
                        ... 56 more
                        Last edited by gowtamcs; Jan 18th, 2011, 09:51 PM.

                        Comment


                        • #14
                          Can you tell us more? Seems like a problem with the datatype mappings - what database? Can you show us the entity and it's _Roo_Entity / rev engineered version?

                          Ken

                          Comment


                          • #15
                            Hello karen, here is the _roo_entity. I am using Hibernate with oracle as my database am conencting to is oracle.

                            // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
                            // You may push code into the target .java compilation unit if you wish to edit any member(s).

                            package com.enets.db;

                            import com.enets.db.NetPackage;
                            import java.lang.String;
                            import java.util.List;
                            import javax.persistence.Column;
                            import javax.persistence.Entity;
                            import javax.persistence.EntityManager;
                            import javax.persistence.GeneratedValue;
                            import javax.persistence.GenerationType;
                            import javax.persistence.Id;
                            import javax.persistence.PersistenceContext;
                            import javax.persistence.Table;
                            import org.springframework.transaction.annotation.Transac tional;

                            privileged aspect NetPackage_Roo_Entity {

                            declare @type: NetPackage: @Entity;

                            declare @type: NetPackage: @Table(name = "NET_PACKAGE", schema = "DBA");

                            @PersistenceContext
                            transient EntityManager NetPackage.entityManager;

                            @Id
                            @GeneratedValue(strategy = GenerationType.AUTO)
                            @Column(name = "NET_PACKAGE_ID")
                            private String NetPackage.netPackageId;

                            public String NetPackage.getNetPackageId() {
                            return this.netPackageId;
                            }

                            public void NetPackage.setNetPackageId(String id) {
                            this.netPackageId = id;
                            }

                            @Transactional
                            public void NetPackage.persist() {
                            if (this.entityManager == null) this.entityManager = entityManager();
                            this.entityManager.persist(this);
                            }

                            @Transactional
                            public void NetPackage.remove() {
                            if (this.entityManager == null) this.entityManager = entityManager();
                            if (this.entityManager.contains(this)) {
                            this.entityManager.remove(this);
                            } else {
                            NetPackage attached = NetPackage.findNetPackage(this.netPackageId);
                            this.entityManager.remove(attached);
                            }
                            }

                            @Transactional
                            public void NetPackage.flush() {
                            if (this.entityManager == null) this.entityManager = entityManager();
                            this.entityManager.flush();
                            }

                            @Transactional
                            public NetPackage NetPackage.merge() {
                            if (this.entityManager == null) this.entityManager = entityManager();
                            NetPackage merged = this.entityManager.merge(this);
                            this.entityManager.flush();
                            return merged;
                            }

                            public static final EntityManager NetPackage.entityManager() {
                            EntityManager em = new NetPackage().entityManager;
                            if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
                            return em;
                            }

                            public static long NetPackage.countNetPackages() {
                            return entityManager().createQuery("select count(o) from NetPackage o", Long.class).getSingleResult();
                            }

                            public static List<NetPackage> NetPackage.findAllNetPackages() {
                            return entityManager().createQuery("select o from NetPackage o", NetPackage.class).getResultList();
                            }

                            public static NetPackage NetPackage.findNetPackage(String id) {
                            if (id == null || 0 == id.length()) return null;
                            return entityManager().find(NetPackage.class, id);
                            }

                            public static List<NetPackage> NetPackage.findNetPackageEntries(int firstResult, int maxResults) {
                            return entityManager().createQuery("select o from NetPackage o", NetPackage.class).setFirstResult(firstResult).setM axResults(maxResults).getResultList();
                            }

                            }
                            Last edited by gowtamcs; Jan 18th, 2011, 09:51 PM.

                            Comment

                            Working...
                            X