imixs / imixs-jsf-example

Imixs JEE Web Example Application
8 stars 9 forks source link

Issue in load of table data. #33

Closed lodhipra closed 5 years ago

lodhipra commented 5 years ago

I have my TABLE as

CREATE TABLE MASTER_CALLER_TYPES( CALLER_TYPE_ID int AUTO_INCREMENT NOT NULL, CALLER_TYPE_NAME nvarchar(500) NOT NULL, CALLER_TYPE_DESC nvarchar(500) NULL, IS_ACTIVE int NULL, SORT_ORDER int NULL, PRIMARY KEY (CALLER_TYPE_ID));

and to retrieve data i have designed a controller as:

public class CallerController implements Serializable {

private static final long serialVersionUID = 1L;
private ArrayList<SelectItem> CallerSelection;
@EJB
DocumentService documentSerivce;

public ArrayList<SelectItem> getTeamSelection() {
    System.out.println("IN Caller CONTROLLER 1");

    CallerSelection = new ArrayList<SelectItem>();

         String query = "SELECT caller FROM master_caller_types AS caller ";
    List<ItemCollection> col1 = documentSerivce.getDocumentsByQuery(query);
//It generates an error in retriving data here as  **### schema in not defined in Entity Manager** 

System.out.println("IN TEAM CONTROLLER 2 ");

    for(ItemCollection aworkitem : col1)
    {
        String sName1 = aworkitem.getItemValueString("CALLER_TYPE_NAME");
        System.out.println( sName1);
    }
        System.out.println("IN Caller CONTROLLER  3 ");

    return CallerSelection;
}

}

Here i want to retrieve caller name list from the table.

Please help me in Solving this problem as soon as possible.

lodhipra commented 5 years ago

Server.log file is

Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: Exception Description: Problem compiling [SELECT caller FROM master_caller_types AS caller ]. [19, 38] The abstract schema type 'master_caller_types' is unknown. at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1746) at org.jboss.as.jpa.container.AbstractEntityManager.createQuery(AbstractEntityManager.java:445) at org.imixs.workflow.engine.DocumentService.getDocumentsByQuery(DocumentService.java:834) at org.imixs.workflow.engine.DocumentService.getDocumentsByQuery(DocumentService.java:819) at org.imixs.workflow.engine.DocumentService.getDocumentsByQuery(DocumentService.java:804) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422) at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509) at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:90) at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:101) at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422) at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422) at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422) at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422) at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:40) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53) at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:52) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422) at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422) at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422) at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:237) ... 122 more Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.7.4.v20190115-ad5b7c6b2a): org.eclipse.persistence.exceptions.JPQLException Exception Description: Problem compiling [SELECT caller FROM master_caller_types AS caller ]. [19, 38] The abstract schema type 'master_caller_types' is unknown. at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:157) at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:349) at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:280) at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:165) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:142) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:118) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.(EJBQueryImpl.java:104) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.(EJBQueryImpl.java:88) at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1744) ... 153 more

rsoika commented 5 years ago

You are totally on the wrong way. If you create your own table you need our own data access controller. I suggest to use JPA. This is an easy way to handle java objects. But you need to learn what JPA is and how it works. I can not teach you this. https://www.vogella.com/tutorials/JavaPersistenceAPI/article.html#jpaintro

What you already have is a datasource and a eclipseLink up and running so adding additional JPA objects is quite easy in this situation.

lodhipra commented 5 years ago

sir, can you please explain how you have created your document tables using jpa. Please provide the mechanism of fetching and storing the data from database. using document table.

lodhipra commented 5 years ago

Please provide the mechanism or steps to work with document table and changes or addidtional work i have to make to retrive data from it. as i am using many tables for different purposes.

i got a new term Define schemas , what is this and where i have to define this in my project .

rsoika commented 5 years ago

The document table is created via JPA. You need to take a look into this technology which is part of Java Enterprise. With JPA no manual creation of a table schema is needed. This is all done by the OR-Mapper. But this is outside of the Imixs-Workflow project, as it is a standard technology. Take a look at the following example code:

@javax.persistence.Entity
public class UserGroup implements java.io.Serializable {

    private static final long serialVersionUID = 1L;
    private String id;

    /**
     * default constructor for JPA
     */
    public UserGroup() {
        super();
    }

    public UserGroup(String aid) {
        this.id = aid;
    }

    @Id
    public String getId() {
        return id;
    }
    protected void setId(String aID) {
        id = aID;
    }   
}

This code will create a new table named 'USERGROUP' with a column 'ID'. You just need to add your classes into the existing persitence.xml file and the table will become part of your imixs database.

To access your data objects via JPA you need to inject an entity manager:

@PersistenceContext(unitName = "org.imixs.workflow.jpa")
    private EntityManager manager;
   ....
    public void update() {
           myGroup = new UserGroup("...");
      manager.persist(noAccessGroup);
     }
 ...
   public UserGroup find(id) {
     UserGroup myGroup = manager.find("....");
  }
....

Please note that I can not teach you all this inside the Imxis-Workflow project as this is not the focus of this project. Take a look into the tutorial I posted.