CreateNativeQuery and Non entity class

just want to find out:
a signature of the createNativeQuery() method is
Query createNativeQuery(String sqlString, Class resultClass) My question is can the resultClass be a non entity?
Regards,
Michael

I tried this method of getting a transfer object from my SqlResultSetMapping. The compilation and deployment works very fine but during runtime, I get null as values for every index of my array while the getResultList() returns a list of size 1.
Query query = entityManager.createNativeQuery(SQL_REPORT_AGG_STM_ON_LN_BAL, "LoanCapitalization.reportMapping");
        AggregateStatementLoanBalanceReportData data = null;
        List<AggregateStatementLoanBalanceReportData> returnList = new ArrayList<AggregateStatementLoanBalanceReportData>();
        query.setParameter(1, reportCriteria.getFromDate());
        query.setParameter(2, reportCriteria.getToDate());
        List<Object[]> resultList = query.getResultList();
        System.out.println("resultList.size() >>>>>>>>>> " + resultList.size());
        for (Object[] obj : resultList){
            data = new AggregateStatementLoanBalanceReportData();
            System.out.println("(String)obj[1] >>>>>>>>>> " + (String)obj[1]);
            System.out.println("(String)obj[2] >>>>>>>>>> " + (String)obj[2]);
            System.out.println("(String)obj[3] >>>>>>>>>> " + (String)obj[3]);
            System.out.println("(String)obj[4] >>>>>>>>>> " + (String)obj[4]);
            System.out.println("(String)obj[5] >>>>>>>>>> " + (String)obj[5]);
            System.out.println("(String)obj[6] >>>>>>>>>> " + (String)obj[6]);
            data.setPolicyNumber((String)obj[0]);
            data.setName((String)obj[1]);
            BigDecimal loanPrincipal = new BigDecimal(Double.parseDouble((String)obj[2]));
            data.setLoanPrincipal(loanPrincipal);
            BigDecimal outstandingLoan = new BigDecimal(Double.parseDouble((String)obj[3]));
            data.setOutstandingLoan(outstandingLoan);
            BigDecimal interest = new BigDecimal(Double.parseDouble((String)obj[4]));
            data.setInterest(interest);
            BigDecimal totalOutstanding = outstandingLoan.add(interest);
            data.setTotalOutstanding(totalOutstanding);
            BigDecimal amountPaid = new BigDecimal(Double.parseDouble((String)obj[5]));
            data.setAmountPaid(amountPaid);
            BigDecimal amountLeft = totalOutstanding.subtract(amountPaid);
            data.setAmountLeft(amountLeft);
            System.out.println("the date is " + obj[6]);
            //data.setLastCapitalizationDate(obj[6]);
            data.setFromDate(reportCriteria.getFromDate());
            data.setToDate(reportCriteria.getToDate());
            returnList.add(data);
        }the size prints 1
but other printline print null
what could be wrong with this

Similar Messages

  • Uses a non-entity as target entity

    Hi everyone,
    I need your help because I am working on a project j2ee6
    I am using jpa (eclipseLink)
    when I created entities without relation, all worked perfectly
    but now that I am trying to set up relation @oneTomany @ManyToOne
    I got this error all the time
    Exception Description: [class com.Domain.User] uses
    [ERROR] a non-entity [class com.Domain.Groups] as target entity in the
    [ERROR] relationship attribute [field groupe].
    here is my user entity :_
    @Entity
    @NamedQueries({
         @NamedQuery(name = "findAllUsers", query="select u from User u"),
         @NamedQuery(name = "findWithLogParam", query="select u from User u where u.Email = :fmail and u.Password = FUNC('sha1', :fpass)")
    public class User implements Serializable{
         private static final long serialVersionUID = 3175161374832714727L;
         @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
         private Long UserId;
         @Column(nullable = false)
         private String Title = "Mr";
         @Column(nullable = false)
         private String Login;
         @Column(nullable = false)
         private String Password;
         @Column(nullable = false)
         private String Firstname;
         @Column(nullable = false)
         private String Lastname;
         @Column(nullable = false)
         private String Email;
         private String Telephone;
         private String Mobile;
         @Temporal(TemporalType.DATE)
         private Date Date_of_birth;
         private String Postcode;
         private String Address;
         private String City;
         private String County;
         private String Region;
         private String Country;
         private String AccountEnabled="On";
         @ManyToOne(optional=false)
    @JoinColumn(name="GROUPID", referencedColumnName="GROUPID")
         private Groups groupe;
         private String Token;
    Here is the entity Groups*
    @Entity
    public class Groups implements Serializable{
         private static final long serialVersionUID = 7092895671981671161L;
         @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
         private Long GroupId;
         @Column(nullable = false)
         private String GroupName;      
         @OneToMany(mappedBy="groupe", targetEntity=User.class, fetch=FetchType.EAGER)
         private List<User> UserList = new ArrayList<User>();
    Here is my persistence.xml*
    <?xml version="1.0" encoding="windows-1252" ?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
                   version="2.0">
         <persistence-unit name="testPU" transaction-type="JTA">
              <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>     
              <jta-data-source>jdbc/UnmodDB</jta-data-source>     
              <class>com.unmod.Domain.User</class>
              <class>com.unmod.Domain.Groups</class>
    ........ other classes ......
              <exclude-unlisted-classes>false</exclude-unlisted-classes>
              <properties>
                   <property name="eclipselink.target-database" value="MySQL"/>
                   <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
                   <property name="eclipselink.ddl-generation.output-mode" value="database" />
              <property name="eclipselink.create-ddl-jdbc-file-name" value="create.sql"/>
              </properties>
         </persistence-unit>
    </persistence>
    It works (compliation works) when I add @Basic however only the user table is created
    Thanks

    Yes it's strange because
    when I comment the oneToMany/ManyToOne parts
    I see hibernate is called
    Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
    INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
    INFO: Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
    INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
    INFO: Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
    INFO: Using provided datasource
    INFO: RDBMS: MySQL, version: 5.5.20
    INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.18 ( Revision: [email protected] )
    INFO: Using dialect: org.hibernate.dialect.MySQLDialect
    INFO: Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
    INFO: instantiating TransactionManagerLookup: org.hibernate.transaction.SunONETransactionManagerLookup
    INFO: instantiated TransactionManagerLookup
    INFO: Automatic flush during beforeCompletion(): disabled
    INFO: Automatic session close at end of transaction: disabled
    INFO: JDBC batch size: 15
    INFO: JDBC batch updates for versioned data: disabled
    INFO: Scrollable result sets: enabled
    but when I added the OneToMany/ManyToOne
    I got
    [INFO] Command deploy failed.
    [ERROR] remote failure: Unknown plain text format. A properly formatted response from a PlainTextActionReporter
    [ERROR] always starts with one of these 2 strings: PlainTextActionReporterSUCCESS or PlainTextActionReporterFAILURE. The response we received from the server was not understood: Signature-Version: 1.0
    [ERROR] message: Error occurred during deployment: Exception while preparing t
    [ERROR] he app : Exception [EclipseLink-28018] (Eclipse Persistence Services
    [ERROR] - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.EntityMa
    [ERROR] nagerSetupException
    [ERROR] Exception Description: Predeployment of P
    [ERROR] ersistenceUnit [chapter02PU] failed.
    [ERROR] Internal Exception: Exce
    [ERROR] ption [EclipseLink-7250] (Eclipse Persistence Services - 2.3.0.v20110
    [ERROR] 604-r9504): org.eclipse.persistence.exceptions.ValidationException%%%
    [ERROR] EOL%%%Exception Description: [class com.unmod.Domain.User] uses a non
    [ERROR] -entity [class com.unmod.Domain.Groups] as target entity in the relat
    [ERROR] ionship attribute [field groupe].. Please see server.log for more det
    [ERROR] ails.
    [ERROR] Exception while invoking class org.glassfish.persistenc
    [ERROR] e.jpa.JPADeployer prepare method : javax.persistence.PersistenceExcep
    [ERROR] tion: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2
    [ERROR] .3.0.v20110604-r9504): org.eclipse.persistence.exceptions.EntityManag
    [ERROR] erSetupException
    [ERROR] Exception Description: Predeployment of Pers
    [ERROR] istenceUnit [chapter02PU] failed.
    [ERROR] Internal Exception: Excepti
    [ERROR] on [EclipseLink-7250] (Eclipse Persistence Services - 2.3.0.v20110604
    [ERROR] -r9504): org.eclipse.persistence.exceptions.ValidationException%%%EOL
    [ERROR] %%%Exception Description: [class com.unmod.Domain.User] uses a non-en
    [ERROR] tity [class com.unmod.Domain.Groups] as target entity in the relation
    [ERROR] ship attribute [field groupe].
    [ERROR] Exception [EclipseLink-28018]
    [ERROR] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.p
    [ERROR] ersistence.exceptions.EntityManagerSetupException
    [ERROR] Exception Descripti
    [ERROR] on: Predeployment of PersistenceUnit [chapter02PU] failed.
    [ERROR] Internal E
    [ERROR] xception: Exception [EclipseLink-7250] (Eclipse Persistence Services
    [ERROR] - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.Validati
    [ERROR] onException
    [ERROR] Exception Description: [class com.unmod.Domain.User] uses
    [ERROR] a non-entity [class com.unmod.Domain.Groups] as target entity in the
    [ERROR] relationship attribute [field groupe].
    it's like eclipseLink wanted to bug me over Hibernate.

  • Abstract Entity classes with Collections

    I trying to figure out a way to have a generics collection in a parent collection that can hold various entity types of the same super-class.
    One thing I've tried was the following:
    @Entity
    public class ParentEnt implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Long id;
        @Column
        private String parentName;
        @OneToMany(mappedBy="parentEnt")
        private Collection<ChildAbs> children;
        /* Methods removed */
    @Entity
    public abstract class ChildAbs implements java.io.Serializable {
        protected static final long serialVersionUID = 1L;
        @Id
        protected Long id;
        @ManyToOne
        protected ParentEnt parentEnt;
        /* Methods removed */
    @Entity
    public class ChildEnt extends ChildAbs implements Serializable {
        @Column
        protected String childName;
    }but this is the error I get:
    Exception [TOPLINK-30005] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
    Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@11b86e7
    Internal Exception: javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [testPU] failed.
    Internal Exception: Exception [TOPLINK-7250] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: [class test.ParentEnt] uses a non-entity [class test.ChildAbs] as target entity in the relationship attribute [private java.util.Collection test.ParentEnt.children].So, it looks like there is no way to have a generics collection for an abstract entity class. Is there another way to accomplish what I want using a generics collection?
    Additionally, entity ChildEnt generates an error due to the abstract class' id property not carrying forward (see Abstract Entities: http://java.sun.com/javaee/5/docs/tutorial/doc/bnbqa.html#bnbqo)
    Exception Description: Entity class [class testprintservices.ChildEnt] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass.Any input would be appreciated.

    As far as my first question, I was trying to make my collection so it can hold various type of entity classes, but now that I think about it, it was a bad idea. For instance, being able to hold ChildEnt and ChildEnt2 in the same collection. If JPA did allow this, it might be possible to save the entities to the DB, but the reverse wouldn't be possible.
    Ok, regarding my 2nd question: I don't understand why having it as @Entity wouldn't. The links (mine and yours) clearly shows that @Id is carried forward in the example they provide. Anyway, since I can't use the superclass in the collection, this is pointless. I'll use the suggested annotation.
    Thanks.

  • EJBQLException, Entity Class, NetBeansv6, TopLink

    Hello I'm new to java and having difficulty with Persistence EntityManager, within persistence.xml I've unselected the 'Include all entity classes' and added the entity class "ImageSpec" to the list provided, and the Entity Class is on the same class path but I still have the following exception. I've researched orm.xml but that looks like it's for deployment scinario's? and not required for development? Any help would be greatly appreciated thank you.
    Exception
    Caused by: Exception [TOPLINK-8034] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.EJBQLException
    Exception Description: Error compiling the query [select object(o) from Images o]. Unknown abstract schema type [Images].
            at oracle.toplink.essentials.exceptions.EJBQLException.unknownAbstractSchemaType(EJBQLException.java:494)
    Entity Class
    package org.comp.app.ds.ajax;
    import java.io.Serializable;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.Table;
    import org.json.JSONArray;
    @Entity
    @Table(name="Images")
    public class ImageSpec implements Serializable {
      private Long imgId;
      private String imgDescription;
      private Long imgFileSize;    
      private String imgFilePath;
      private String imgFileType;
      public ImageSpec() { }
      public JSONArray toJSON() {
         JSONArray thisJSON = new JSONArray();
         thisJSON.put(this.getImgId());
         thisJSON.put(this.getImgDescription());
         thisJSON.put(this.getImgFileSize());
         thisJSON.put(this.getImgFilePath());
         thisJSON.put(this.getImgFileType());
         return thisJSON;
      @Id
      public Long getImgId() {
        return imgId;
      public String getImgDescription() {
        return imgDescription;
      public Long getImgFileSize() {
        return imgFileSize;
      public String getImgFilePath() {
        return imgFilePath;
      public String getImgFileType() {
        return imgFileType;
      public void setImgId(Long imgId) {
        this.imgId = imgId;
      public void setImgDescription(String imgDescription) {
        this.imgDescription = imgDescription;
      public void setImgFileSize(Long imgFileSize) {
        this.imgFileSize = imgFileSize;
      public void setImgFilePath(String imgFilePath) {
        this.imgFilePath = imgFilePath;
      public void setImgFileType(String imgFileType) {
        this.imgFileType = imgFileType;
    persistence.xml
    <persistence-unit name="AppPU" transaction-type="JTA">
        <provider>oracle.toplink.essentials.PersistenceProvider</provider>
        <jta-data-source>jdbc/appDB</jta-data-source>
        <class>org.comp.app.ds.ajax.ImageSpec</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <properties>
        </properties>
      </persistence-unit>

    By finding a resource on EJB QL, my Query syntax was wrong. Here's an explanation for anybody with the same problem.
    SQL Query Example
    SELECT * FROM TableName
    EJB QL Example
    SELECT OBJECT(i) FROM ImageSpec i
    OBJECT = * (+Select All+)
    i = A made up identifying character (Rule of thumb: use the first character of Entity Class Name)
    ImageSpec = The Entity Class Name (+Not the Database Column Name+)
    See the link URL below for more information:
    http://edocs.bea.com/workshop/docs81/doc/en/core/index.html
    Edited by: Jodda on Feb 22, 2008 7:41 AM - Marked as answered.

  • Adf bc jar for base entity classes and extending them existing  project

    Hi,
    I am using jdev 11.1.1.0 and have created a base workspace/project and adf jar for my base entity classes.
    1. I can consume this base adf bc jar in a separate new consuming workspace and create VO based on base bc classes or create new EOs that extend base bc entity classes.
    2. Furthermore, for an existing consuming project that earlier included src/ of base entity (BC components), i can remove the dependency on bc source and bring in this new adf jar and everything including the view controller and the service/datacontrol works fine.
    The issue i am running into is as follows.
    - In the existing project (#2) above i try to create a couple of entities based on entities in my base jar; associations are automatically brought in. Note i am not overriding any attributes. My intent here is to generate .java and implement some code.
    - I then try to make my existing VOs based on the newly extended entity (VO overview->Entity Objects-> Shuttle NewEntity from Available to Selected)
    - I then try to remove the old EO from selected under VO overview->Entity Objects->Shuttle OldEntity from Selected back
    - I get a warning dialog box that says something to the effect that some viewlinks are dependent on these old EOs in this consuming project.
    - I tried to laboriously analyzed dependencies and it this dialog box does not make any sense as I have already extended EOs and the tooling should be able to let me use these
    My questions
    - Why I am not able to remove old entities from VO dependencies
    - Is it ok to leave the old EOs in "Selected" along with the newly extended EO ? What are the implications for this?
    - I also thought about extending base associations, but did not go anywhere.
    In general, I am ok with consuming an ADF BC jar that has entities etc. but not clear about removing dependencies of base EOs on VOs when entities are extended and consumed in a pre-existing project that used base entities.
    I can send a project if any PM is willing to take a look at it.
    Thanks,
    ps:
    I have already gone over the following info
    http://technology.amis.nl/blog/215/organization-of-bc4j-domain-eo-and-business-vo-package
    .. wants to create an enterprise data model in BC4J, reflecting the Enterprise Data Model set up in the RDBMS. All (or at least most) business rules will be implemented in the Middle Tier – to take the load of the database and also allow developers not comfortable with PL/SQL to define and maintain the business rules. It is clear that this means that all applications that need to access – and manipulate – the database, need to go through the BC4J foundation layer. Martijn wants to define the Entity Objects – and their business rules – only once and share that definition between different projects. Each projects can create its own ViewObjects on top of these shared Enterprise Entity Objects.
    http://radio-weblogs.com/0118231/2005/09/29.html
    I am currently working on a project for a partner where we will be using ADF BC as our model layer for a large application. In order to keep the footprint of each application module down to a reasonable size, we are intending to create a number of separate 'root' application modules for each functional area of the application. Within, these 'root' application modules we will then use nested application modules to further partition the application. All of the application modules will be accessing the same datasource and will need access to the same database objects.
    In order to separate our code between the development team and into function areas, our initial thoughts were that we would create an ADF BC model project containing Entity Objects for all of the database tables e.t.c. as these are common amongst all functional areas. We have configured all of the EOs for validation rules, defaulting values and extending doDML() as appropriate. Happy at this stage we then created a simple .jar file to deploy all of the definitions. Upon creating a new ADF BC project for each functional area we added the jar file as a library import into the new project. However when we the tried to create some new View Objects via the JDev Wizard we were unable to see the imported Entity Objects.
    Is the only way to share Entity Object definitions between different ADF BC projects to manually copy the source definition files into the new projects src directory? Since this would mean multiple copies of the same components, it could prove to be a maintenance nightmare.Is there a way of doing it without creating multiple copies of the same object definitions?
    The developer is spot on in their ideas of layering and reuse, and even has created a library for their reusable entities. This last step is not something everyone thinks to do. The missing step is known as "importing" components, so with that one extra bit of knowledge under his belt, he should be able to do exactly what he envisions. My little article called Difference Between Adding and Importing Business Components tries to explain the difference and gives the menu options to choose to perform the importing.
    Difference between adding and importing BC4J
    http://radio-weblogs.com/0118231/stories/2005/08/11/differenceBetweenAddingAndImportingBusinessComponents.html
    Working with Libraries of Reusable Business Components
    http://download.oracle.com/docs/cd/B32110_01/web.1013/b25947/bcadvgen.htm#CHEFECGD

    Hi,
    since you followed the OC4J developer guide I think this question might be better handled there as well
    OC4J
    So in case you don't get an answer here on the forum, try it on the OC4J forum
    Frank

  • ToString() and Comparable T on a JAXB generated entity class

    Hello,
    I'm trying to create a distributed system and therefore I have all my entity classes present in my Java EE app and hosted as a web service. The Swing frontend app autogenerate the entity classes for use in the presentation.
    I'm having some trouble using the Collections.sort() since a generated entity cannot implement an interface, does anyone have a hint to how i can solve this issue?
    Also, I need to override the toString() so that I can put an entity directly in a eg. JCombobox and it is presented with the return of my custom toString() but if I override the toString() in my original entity in my backend app, then this method is not generated in my frontend app.
    Thanks in advance!
    Nicklas

    Hello,
    I'm trying to create a distributed system and therefore I have all my entity classes present in my Java EE app and hosted as a web service. The Swing frontend app autogenerate the entity classes for use in the presentation.
    I'm having some trouble using the Collections.sort() since a generated entity cannot implement an interface, does anyone have a hint to how i can solve this issue?
    Also, I need to override the toString() so that I can put an entity directly in a eg. JCombobox and it is presented with the return of my custom toString() but if I override the toString() in my original entity in my backend app, then this method is not generated in my frontend app.
    Thanks in advance!
    Nicklas

  • About integration between SAP and non-SAP applications via javaidoc classes

    Hi,All
    Now we are implementing a SAP-Retail project,we encounter a problem of integration between SAP and non-SAP applications(POS),we want to set Inbound/Outbound between SAP and POS applications realtimely,POS can connect to the SAP system via VPN,weather it can be implemented?
    I conceive to implement it with SAP Java Connector IDoc Class,I don't know weather it is the best solution?If not,please give some other proposal.
    I have download the classes from SAP website and try it with the samples provided by SAP(JCoIDocSample1.java/JCoIDocSample3.java),In my testing,Inbound is succeed,but,in SAP-Retail IS,standard Outbound message type is defined via file port,some one told me that SAP Java Connector IDoc Class can only receive idocs from tRFC port?is it true?If not,please tell me how to deploy in SAP so java program can receive idocs from file port?

    We too are interested in finding information on integration between SAP and Intergraph.  Were you able to obtain information and I was wondering if could share this with us.
    Thanks,
    Sue
    City of Edmonton

  • Using inherited fields from a non entity super class in a compound PK class

    Hi,
    Suppose you have a POJO class called BaseClass, which is decorated with @MappedSuperclass, so that its sub classes can become EJB entities:
    @MappedSuperclass
    public class BaseClass implements Serializable {
    protected int field1;
    protected int field2;
    }EntityOne class is a sub class of BaseClass and an EJB 3.0 entity.
    @Entity
    public class EntityOne extends BaseClass {
    @Id
    protected int field3
    }Everything would be fine up to this point. The problem begins when the following situation is given:
    EntityOne shall have a compound primary key, which is a combination of filed1, field2 and field3!
    Off course, I can define a primary key class EntityOnePK:
    public class EntityOnePK implements Serializable {
      protected int filed1;
      protected int filed2;
      protected int filed3;
      public int hashCode(){...}
      public boolean equals(....){....}
    }But the fields 1 and 2 can not be decorated with @Id annotation, since they are not defined in an entity class!
    Any ideas of how to resolve this situation?
    I had a look in the specification and some articles. I have to admit that the new inheritance features in the EJB 3.0 framework are a real improvement . However, in a bigger scale application, where persistence is only one of many aspects of the system, the introduced methodology of inheritance is not sufficient, i.e. the BaseClass has a lot of subclasses and is used in many packets as a POJO.
    To be more concrete, in our case there are good reasons not define the base class as an entity, mainly to avoid a corresponding table in the used DB, which is also interfacing with other software systems.
    Thanks in advance for your help,
    Mehran

    JAZN is indeed supported for a standalone client. Make sure that the client JVM is also configured for JAAS and has jazn.jar in the classpath.
    Regards,
    -Lee

  • Custom non-PersistenceCapable classes used as keys in Maps and/or SortedMaps?

    Hi all,
    I need to support custom non-PC classes as keys in SortedMaps. It takes
    custom coding to the Kodo API right now, and before embarking down that
    road, I wondered if anyone out there has already done this and is willing
    to share that code.
    Thanks!
    --matthew

    Matthew-
    Can you just make the key implement Serializable and store it as a blob
    (which means that you will not be able to query against it), or do you
    have other restrictions?
    In article <c90i4b$22k$[email protected]>, Matthew T. Adams wrote:
    Hi all,
    I need to support custom non-PC classes as keys in SortedMaps. It takes
    custom coding to the Kodo API right now, and before embarking down that
    road, I wondered if anyone out there has already done this and is willing
    to share that code.
    Thanks!
    --matthew--
    Marc Prud'hommeaux
    SolarMetric Inc.

  • Non persisted fields in entity class

    Is it possible to declare a field of an entity class such that it does not get persisted?

    Yes, use the JPA @Transient annotation (or transient field attribute).
    -- James : http://www.eclipselink.org

  • Weird exception: Cannot instantiate non-persistent class: java.util.Map

    java.lang.UnsupportedOperationException: Cannot instantiate non-persistent class: java.util.Map
         at com.sleepycat.persist.impl.NonPersistentFormat.newInstance(NonPersistentFormat.java:45)
         at com.sleepycat.persist.impl.PersistEntityBinding.readEntity(PersistEntityBinding.java:89)
         at com.sleepycat.persist.impl.PersistEntityBinding.entryToObject(PersistEntityBinding.java:61)
         at com.sleepycat.persist.PrimaryIndex.put(PrimaryIndex.java:338)
         at com.sleepycat.persist.PrimaryIndex.put(PrimaryIndex.java:299)
         at com.xx.support.dbd.IdentityDataAccessor.insert(IdentityDataAccessor.java:33)
         at com.xx.support.dbd.BerkeleyDBAccountStorage.saveUser(BerkeleyDBAccountStorage.java:95)
         at com.xx.support.bdb.BerkeleyDBAccountStorageTests.initBerkeleyDBData(BerkeleyDBAccountStorageTests.java:38)
         at com.xx.support.bdb.BerkeleyDBAccountStorageTests.setUp(BerkeleyDBAccountStorageTests.java:28)
         at junit.framework.TestCase.runBare(TestCase.java:125)
         at junit.framework.TestResult$1.protect(TestResult.java:106)
         at junit.framework.TestResult.runProtected(TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:118)
         at junit.framework.TestSuite.runTest(TestSuite.java:208)
         at junit.framework.TestSuite.run(TestSuite.java:203)
    What's the root cause of this exception?

    I wrote a small test using the classes you included
    in your message and I am able to retrieve the user by
    key, as in the code above. So I'm not sure what
    you're doing that is causing the problem. Please
    send a small test that reproduces the problem.Oops, I forgot to include the source for the test I wrote. Here it is.
    import java.io.File;
    import java.util.HashMap;
    import java.util.Map;
    import com.sleepycat.je.DatabaseException;
    import com.sleepycat.je.Environment;
    import com.sleepycat.je.EnvironmentConfig;
    import com.sleepycat.persist.EntityStore;
    import com.sleepycat.persist.PrimaryIndex;
    import com.sleepycat.persist.StoreConfig;
    import com.sleepycat.persist.model.Entity;
    import com.sleepycat.persist.model.Persistent;
    import com.sleepycat.persist.model.PrimaryKey;
    public class Test {
        @Persistent
        public static class SimplePrincipal {
            protected String name;
            public SimplePrincipal(String username) {
                this.name = name;
            public SimplePrincipal() {}
        @Entity
        public static class SimpleUser extends SimplePrincipal {
            @PrimaryKey
            private String key;
            private Map properties;
            public SimpleUser() {
                super();
                this.properties = new HashMap();
            public SimpleUser(String username) {
                super(username);
                this.properties = new HashMap();
            public void setKey(String key){
                this.key = key;
            public void addPropertity(String name, String value) {
                this.properties.put(name, value);
            @Override
            public String toString() {
                return "[SimpleUser key: " + key + " name: " + name + ']';
        private Environment env;
        private EntityStore store;
        private PrimaryIndex<String, SimpleUser> primaryIndex;
        private void open()
            throws DatabaseException {
            EnvironmentConfig envConfig = new EnvironmentConfig();
            envConfig.setAllowCreate(true);
            envConfig.setTransactional(true);
            env = new Environment(new File("./data"), envConfig);
            StoreConfig storeConfig = new StoreConfig();
            storeConfig.setAllowCreate(true);
            storeConfig.setTransactional(true);
            store = new EntityStore(env, "test", storeConfig);
            primaryIndex = store.getPrimaryIndex(String.class, SimpleUser.class);
        private void close()
            throws DatabaseException {
            store.close();
            env.close();
        private void execute()
            throws DatabaseException {
            SimpleUser user = new SimpleUser("test");
            user.setKey("testkey");
            primaryIndex.put(user);
            user = primaryIndex.get("testkey");
            System.out.println(user);
        public static void main(String[] args)
            throws DatabaseException {
            Test test = new Test();
            test.open();
            test.execute();
            test.close();
    }Mark

  • Validation for Unique Name and Non-AlphaNumeric Characters

    Hi All,
    How to do Unique name and Non-Alpha Numeric Characters Validation?
    Name should be unique and only allow alphanumeric characters.
    Where all validations must be done? In EOImpl or any other file?
    Plz help
    Thanks,
    Sk

    SK
    Here are the steps you need to perform to check duplicate Employee Names need not entered by user.
    First create a VVO in your schema.server package(that of EO) with the following query.Generate both VVOImpl and VVORowImpl file.
    select full_name
    from fwk_tbx_employees
    where full_name =:1Now add this VVO to your VAM means give instance to it.
    Now open the VVOImpl and write below code to execute query based on new name entered by user
        public void initQuery(String name)
          setWhereClauseParams(null); // Always reset
          setWhereClauseParam(0, name);
          executeQuery();
        }Now open Your Entity Expert class and add below method in it
       public boolean isEmployeeNameExists(String name)
         boolean isExists = false;
               // Note that we want to use a cached, declaratively defined VO instead of creating
               // one from a SQL statement which is far less performant.
         EmployeeNameVVOImpl employeeNameVVO =
           (EmployeeNameVVOImpl)findValidationViewObject("EmployeeNameVVO1");
         employeeNameVVO.initQuery(name);
         // We're just doing a simple existance check.  If we don't find a match, return false.
         if (employeeNameVVO.hasNext())
           isExists = true;
         return isExists;
       }Now you need to call this expert class method from setter method of EOImpl for name.so Open your EOImpl file and go to setter method of name
          if ((value != null) || (!("".equals(value.trim()))))
            EmployeeEntityExpert expert = getEmployeeEntityExpert(getOADBTransaction());
            if (!(expert.isEmployeeNameExists(value)))
                throw new OAException("Duplicate Employee Name", OAException.ERROR);
          }Remember to write code above setAttributeInternal.
    Hope it helps!!!!
    Let me know if you have queries in it.
    Thanks
    AJ

  • Retrieving spatial and non spatial data in one query

    Hello. I am having slight difficulties using JDBC to retrieve both spatial and non spatial data in the same query. The following is code from a sample program of mine that retrives spatial data from spatial tables.
    (In spatialquery geom is a geometry column and city is simply the name of the city):
    try
    Geometry geom = null;
    String database = "jdbc:oracle:thin:@" + m_host + ":" + m_port + ":" + m_sid;
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = (OracleConnection)DriverManager.getConnection(database, sUsername, sPassword);
    GeometryAdapter sdoAdapter =
    OraSpatialManager.getGeometryAdapter("SDO", "8.1.7", STRUCT.class, null, null, con);
    String spatialquery = "SELECT a1.geom, a1.city \n" +
    "FROM cities a1";
    Statement stmt = con.createStatement();
    OracleResultSet rs = (OracleResultSet) stmt.executeQuery(spatialquery);
    int i = 0;
    int noOfFeatures = 2;
    while (rs.next())
    for(i = 1; i <= noOfFeatures; i++)
    STRUCT dbObject = (STRUCT)rs.getObject(i);
    try
    geom = sdoAdapter.importGeometry(dbObject);
    catch(GeometryInputTypeNotSupportedException e)
    System.out.println("Input Type not supported");
    catch(InvalidGeometryException e)
    System.out.println("Invalid geometry");
    System.out.println(geom);
    }//end while loop
    This retrieves the sptial data fine, however when I attempt to retreive the non-spatial data I keep getting a "ClassCastException" error. I understand it is something to do with "STRUCT dbObject = (STRUCT)rs.getObject(i);" line. Can anyone tell me how to retrieve both spatial and non-spatial data in the one query using JDBC. I have tried nearly everything at this stage. Cheers joe

    Theresa A Radke
    Posts: 20
    OTN Member Since: Jul, 2001
    retrieving spatial and non spatial in same query. May 23, 2003 12:02 AM
    retrieving spatial and non spatial in same query.

  • JAX-RPC And Non-Java Web Service

    Hi,
    This is a total shot in the dark. I'm attempting to consume an RPC web service developed in Delphi. I've created a JAX-RPC client in NetBeans from the published WSDL, attached below. I've created calls to several of the procedures available. What's bizarre, at least to me, is that half of them work fine and half of them don't. In all cases where they don't I'm getting a returns SOAP envelope indicated an access violation, attached below. There are no errors in any of the server logs and the developer assures me that the procedures do, in fact, work from his client (also developed conveniently enough in Delphi).
    I'm willing to take him at face value for the moment and assume that the problem is in my client implementation, although I have no idea where it would lie. The only difference I've been able to gather between the features which work and those that don't is the size of the return package...it would most likely be much larger than the ones that don't work.
    The service is an ISAPI dll running under IIS on Windows Server 2003. Any clues or guidance anyone would be willing to provide would be most welcome. On to the files:
    There wasn't enough room to post the entire thing so I've included one working (CheckStock) and non-working (GetLibTrace) function.
    WSDL:
    <?xml version="1.0" encoding="UTF-8"?>
    <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="IInnovaServiceservice" targetNamespace="http://tempuri.org/" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/">
      <message name="CheckStock2Request">
        <part name="OPC" type="xs:string"/>
      </message>
      <message name="CheckStock2Response">
        <part name="QTY" type="xs:int"/>
        <part name="messages" type="xs:string"/>
        <part name="return" type="xs:int"/>
      </message>
      <message name="GetLibTrace5Request">
        <part name="LibName" type="xs:string"/>
      </message>
      <message name="GetLibTrace5Response">
        <part name="dimensions" type="xs:string"/>
        <part name="messages" type="xs:string"/>
        <part name="return" type="xs:int"/>
      </message>
      <portType name="IInnovaService">
        <operation name="CheckStock">
          <input message="tns:CheckStock2Request"/>
          <output message="tns:CheckStock2Response"/>
        </operation>
        <operation name="GetLibTrace">
          <input message="tns:GetLibTrace5Request"/>
          <output message="tns:GetLibTrace5Response"/>
        </operation>
      </portType>
      <binding name="IInnovaServicebinding" type="tns:IInnovaService">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="CheckStock">
          <soap:operation soapAction="urn:InnovaServiceIntf-IInnovaService#CheckStock" style="rpc"/>
          <input>
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:InnovaServiceIntf-IInnovaService"/>
          </input>
          <output>
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:InnovaServiceIntf-IInnovaService"/>
          </output>
        </operation>
        <operation name="GetLibTrace">
          <soap:operation soapAction="urn:InnovaServiceIntf-IInnovaService#GetLibTrace" style="rpc"/>
          <input>
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:InnovaServiceIntf-IInnovaService"/>
          </input>
          <output>
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:InnovaServiceIntf-IInnovaService"/>
          </output>
        </operation>
      </binding>
      <service name="IInnovaServiceservice">
        <port name="IInnovaServicePort" binding="tns:IInnovaServicebinding">
          <soap:address location="http://172.20.10.145:8080/innovaservice.dll/soap/IInnovaService"/>
        </port>
      </service>
    </definitions>My client:
    package com.signet.innova.client;
    import com.signet.innova.client.interfaces.IInnovaService;
    import com.signet.innova.client.interfaces.IInnovaServiceservice_Impl;
    import java.net.URL;
    import java.rmi.RemoteException;
    import java.util.ArrayList;
    import javax.xml.namespace.QName;
    import javax.xml.rpc.Stub;
    import javax.xml.rpc.holders.Holder;
    import javax.xml.rpc.holders.IntHolder;
    import javax.xml.rpc.holders.StringHolder;
    import javax.xml.soap.MessageFactory;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.ws.Dispatch;
    import javax.xml.ws.Service;
    public class InnovaClient {
        private void testConnection() {
            Stub stub = createProxy();
            IInnovaService service = (IInnovaService) stub;
            StringHolder sh1 = new StringHolder();
            StringHolder sh2 = new StringHolder();
            StringHolder sh3 = new StringHolder();
            IntHolder ih1 = new IntHolder();
            IntHolder ih2 = new IntHolder();
            IntHolder ih3 = new IntHolder();
            try {
                System.out.println("Calling checkStock()");
                service.checkStock("0103877866", ih1, sh1, ih2);
                System.out.println(" service returned => " + ih1.value + ":" + sh1.value + ":" + ih2.value);
            } catch (RemoteException re) {
                System.out.println(" service returned => " + re.toString());
            try {
                System.out.println("Calling getLibTrace()");
                service.getLibTrace("REGULAR", sh1, sh2, ih3);
                System.out.println(" service returned => " + sh1.value + ":" + sh2.value + ":" + ih1.value);
            } catch (RemoteException re) {
                System.out.println(" service returned => " + re.toString());
        private Stub createProxy() {
            return (Stub) (new IInnovaServiceservice_Impl().getIInnovaServicePort());
        public static void main(String[] args) {
            InnovaClient client = new InnovaClient();
            System.out.print("Running testConnection()...");
            client.testConnection();
    }The request and response packets are in my reply below. Ran out of characters. :o)
    Edited by: Pablo_Vadear on Dec 22, 2009 11:19 PM

    Correction from above...".it would most likely be much larger than the ones that don't work" should have been "it would most likely be much larger IN THE ONES THAT DON'T WORK". Sorry.
    The request:
    POST /innovaservice.dll/soap/IInnovaService HTTP/1.1
    Content-Type: text/xml; charset=utf-8
    Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Content-Length: 484
    SOAPAction: "urn:InnovaServiceIntf-IInnovaService#CheckStock"
    User-Agent: Java/1.6.0_17
    Host: 172.20.10.145:8080
    Connection: keep-alive
    <?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="urn:InnovaServiceIntf-IInnovaService" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><env:Body><ns0:CheckStock><OPC xsi:type="xsd:string">0103877866</OPC></ns0:CheckStock></env:Body></env:Envelope>POST /innovaservice.dll/soap/IInnovaService HTTP/1.1
    Content-Type: text/xml; charset=utf-8
    Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Content-Length: 491
    SOAPAction: "urn:InnovaServiceIntf-IInnovaService#GetLibTrace"
    User-Agent: Java/1.6.0_17
    Host: localhost:8080
    Connection: keep-alive
    <?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="urn:InnovaServiceIntf-IInnovaService" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><env:Body><ns0:GetLibTrace><LibName xsi:type="xsd:string">REGULAR</LibName></ns0:GetLibTrace></env:Body></env:Envelope>And the response:
    <?xml version="1.0"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><NS1:CheckStockResponse xmlns:NS1="urn:InnovaServiceIntf-IInnovaService"><return xsi:type="xsd:int">0</return><QTY xsi:type="xsd:int">0</QTY><messages xsi:type="xsd:string">Item 0103877866 retrieved OK.
    Right side OPC.
    </messages></NS1:CheckStockResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
    HTTP/1.1 200 OK
    Date: Tue, 22 Dec 2009 23:18:40 GMT
    Server: Microsoft-IIS/6.0
    Content-Type: text/xml
    Content-Length: 486
    <?xml version="1.0"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultactor/><faultcode>SOAP-ENV:Server</faultcode><faultstring>Access violation at address 00000000. Write of address 00000000</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>Any help appreciated.
    Edited by: Pablo_Vadear on Dec 22, 2009 11:23 PM

  • "Abstract" method in a non-abstract class

    Hi all.
    I have a class "SuperClass" from which other class are extended...
    I'd like to "force" some methods (method1(), method2, ...) to be implemented in the inherited classes.
    I know I can accomplish this just implementing the superclass method body in order to throw an exception when it's directly called:
    void method1(){
    throw new UnsupportedOperationException();
    }...but I was wondering if there's another (better) way...
    It's like I would like to declare some abstract methods in a non-abstract class...
    Any ideas?

    The superclass just models the information held by
    the subclasses.
    The information is taken from the database, by
    accessing the proper table (one for each subclass).??
    What do you mean by "models the information"?
    You should use inheritance (of implementation) only when the class satisfies the following criteria:
    1) "Is a special kind of," not "is a role played by a";
    2) Never needs to transmute to be an object in some other class;
    3) Extends rather than overrides or nullifies superclass;
    4) Does not subclass what is merely a utility class (useful functionality you'd like to reuse); and
    5) Within PD: expresses special kinds of roles, transactions, or things.
    Why are you trying to force these mystery methodsfrom the superclass?
    It's not mandatory for me to do it... I 'd see it
    just like a further way to check that the subclasses
    implements these methods, as they have to do.That's not a good idea. If the superclass has no relation to the database, it shouldn't contain methods (abstract or otherwise) related to database transactions.
    The subclasses are the classes that handle db
    transaction.
    They are designed as a binding to a db table.And how is the superclass designed to handle db transactions? My guess (based on your description) is that it isn't. That should tell you right away that the subclasses should not extend your superclass.

Maybe you are looking for