Java Persistance: Question about query within inheritance class

In father class here is the annotation:
@Entity
@Table(name = "CONTENT_MEDIA")
@Inheritance(strategy=javax.persistence.InheritanceType.JOINED)
@DiscriminatorColumn(name="CONTENT_TYPE", discriminatorType=javax.persistence.DiscriminatorType.INTEGER)
@DiscriminatorValue("4")
In son class here is the annotation and query:
@Entity
@Table(name = "ISBN_BOOK")
@DiscriminatorValue("1000001")
@NamedQueries( {
@NamedQuery(name = "ISBN_BOOK.findViaISBN", query = "SELECT g FROM ISBNBook g WHERE g.ISBNnumber = :isbn")
When I do the query, the result is:
Internal Exception: org.apache.derby.client.am.SqlException: Comparisons between 'INTEGER' and 'CHAR' are not supported.Error Code: -1
Call:SELECT t0.CONTENT_ID, t0.CONTENT_TYPE, t0.OBTAIN_DATE, t0.SEARCH_TIMES, t0.LAST_SEARCH_DATE, t1.CONTENT_ID, t1.BOOK_NAME, t1.AUTHOR, t1.ISBN_NUMBER, t1.CURRENT_LOCATION FROM CONTENT_MEDIA t0, ISBN_BOOK t1 WHERE ((t1.ISBN_NUMBER = CAST (? AS VARCHAR(32672) )) AND ((t1.CONTENT_ID = t0.CONTENT_ID) AND (t0.CONTENT_TYPE = '1000001')))
bind => [AAA]
The problem is: t0.CONTENT_TYPE = '1000001'. I have set the column to Integer, why the JPA use the char?
Can anyone solve the problem for me?

In father class here is the annotation:
@Entity
@Table(name = "CONTENT_MEDIA")
@Inheritance(strategy=javax.persistence.InheritanceType.JOINED)
@DiscriminatorColumn(name="CONTENT_TYPE", discriminatorType=javax.persistence.DiscriminatorType.INTEGER)
@DiscriminatorValue("4")In son class here is the annotation and query:
@Entity
@Table(name = "ISBN_BOOK")
@DiscriminatorValue("1000001")
@NamedQueries( {
@NamedQuery(name = "ISBN_BOOK.findViaISBN", query = "SELECT g FROM ISBNBook g WHERE g.ISBNnumber = :isbn")
})When I do the query, the result is:
Internal Exception: org.apache.derby.client.am.SqlException: Comparisons between 'INTEGER' and 'CHAR' are not supported.Error Code: -1
Call:SELECT t0.CONTENT_ID, t0.CONTENT_TYPE, t0.OBTAIN_DATE, t0.SEARCH_TIMES, t0.LAST_SEARCH_DATE, t1.CONTENT_ID, t1.BOOK_NAME, t1.AUTHOR, t1.ISBN_NUMBER, t1.CURRENT_LOCATION FROM CONTENT_MEDIA t0, ISBN_BOOK t1 WHERE ((t1.ISBN_NUMBER = CAST (? AS VARCHAR(32672) )) AND ((t1.CONTENT_ID = t0.CONTENT_ID) AND (t0.CONTENT_TYPE = '1000001')))
bind => [AAA]he problem is: t0.CONTENT_TYPE = '1000001'. I have set the column to Integer, why the JPA use the char?
Can anyone solve the problem for me?
I think now it is more readable.
(use code tags pls)

Similar Messages

  • A question about non-static inner class...

    hello everybody. i have a question about the non-static inner class. following is a block of codes:
    i can declare and have a handle of a non-static inner class, like this : Inner0.HaveValue hv = inn.getHandle( 100 );
    but why cannot i create an object of that non-static inner class by calling its constructor? like this : Inner0.HaveValue hv = Inner0.HaveValue( 100 );
    is it true that "you can never CREATE an object of a non-static inner class( an object of Inner0.HaveValue ) without an object of the outer class( an object of Inner0 )"??
    does the object "hv" in this program belong to the object of its outer class( that is : "inn" )? if "inn" is destroyed by the gc, can "hv" continue to exist?
    thanks a lot. I am a foreigner and my english is not very pure. I hope that i have expressed my idea clearly.
    // -------------- the codes -------------------
    import java.util.*;
    public class Inner0 {
    // definition of an inner class HaveValue...
    private class HaveValue {
    private int itsVal;
    public int getValue() {
    return itsVal;
    public HaveValue( int i ) {
    itsVal = i;
    // create an object of the inner class by calling this function ...
    public HaveValue getHandle( int i ) {
    return new HaveValue( i );
    public static void main( String[] args ) {
    Inner0 inn = new Inner0();
    Inner0.HaveValue hv = inn.getHandle( 100 );
    System.out.println( "i can create an inner class object." );
    System.out.println( "i can also get its value : " + hv.getValue() );
    return;
    // -------------- end of the codes --------------

    when you want to create an object of a non-static inner class, you have to have a reference of the enclosing class.
    You can create an instance of the inner class as:
    outer.inner oi = new outer().new inner();

  • Question about access non-public class from other package.

    Hi, everyone!
    Suppose class A and class B are in the same java file of package pkg1
    -- A.java. So, A is a public class and B is a non-public class.
    If I want to access class B from another class class C and class
    C is in package pkg2. When compiling, an error occurs indicating
    that class B is not visible to class C.
    So, If I defined serveral classes in one java file and I want to
    access every class from other package. How should I do?
    (I think in one java file, there should be only one public class and
    only the public class can be accessed from other package.)
    Thanks in advance,
    George

    So, If I defined serveral classes in one java file and
    I want to
    access every class from other package. How should I
    do? As you already seem to know, there is at most one public class allowed per source file (at least, with javac and most popular compilers). So if you want more than one public class, you will need to use more than one file...

  • Question about view/controller/nib class design

    Assume you need to make an application with, let's say, 15 different views in total. There are two extreme design choices you can use to implement the app:
    1) Every single view has its own view controller and a nib file. Thus you end up with 15 controller classes and 15 nib files (and possibly a bunch of view classes if any of your views needs to be somehow specialized).
    2) You have only one controller which manages all the views, and one nib file from which they are loaded.
    AFAIK Apple and many books recommend going purely with option #1. However, going with this often results in needless complexity, large amounts of classes (and nib files) to be managed and complicated class dependencies, especially if some of the views (and thus their controllers) interact with each other or share something (something which would be greatly simplified if all these related views were handled by one single controller class).
    Option #2 also usually ends up being very complex. The major problem is that the single controller will often end up being enormous, handling tons of different (and usually unrelated) things (which is just outright bad design). This is seldom a good design, unless your application consists of only a few views which are closely related to each other (and thus it makes sense for one single controller class to handle them).
    (Option #2 also breaks the strictest interpretation of the MVC pattern, but that's not really something I'm concerned about. I'm concerned about simple design, not about following a programming pattern to the letter.)
    A design somewhere in between the two extremes often seems to be the best approach. However, since I don't have decades of Cocoa programming experience, I would like to hear some opinions about this subject matter from people with more experience on that subject. (I do have object-oriented programming experience, but I have only relatively recently started programming for the iPhone and thus Cocoa and its design patterns are relatively new to me, so I'm still learning.)

    Somehow I get the feeling that my question was slightly misunderstood.
    I was not asking "which one of these two designs do you think is better, option #1 or option #2?" I already said in my original post that option #2 is bad design (unless your application consists of just one or two views). That's not the issue.
    The issue is that from my own experience trying to adhere very strictly to the "every single view must have its own view controller and nib file" often results in needless complexity. Of course this is not always the case, but sometimes you end up having controller classes which perform very similar, if not even the exact same actions, resulting in code repetition. (An OO'ish solution to this problem would be to have a common base class for these view controllers where the common functionality has been grouped, but this often just adds to the overall complexity of the class hierarchy rather than alleviating it.)
    As an example, let's assume that you have a set of help screens (for example one help screen for each major feature of the app) and a view where you can select which help view to show. Every one of these views has, for example, a button to immediately exit the help system. If you had one single controller class managing these views, this becomes simpler: The controller can switch between any of the views and the buttons of each view (most of them doing the same things) can call back actions on this controller (eg. to return to the help selection or to exit the help screen completely). These help screens don't necessarily have any functionality of their own, so it's questionable what do they would need view controllers of their own. These view controllers would basically be empty because there's nothing special for them to do.
    View controllers might make it easy to use the navigation controller class, but the navigation controller is suitable mainly for utility apps but often not for things like games. (And if you need animated transitions between views, that can be implemented using the UIView animation features.)
    I also have hard time seeing the advantages of adhering strictly to the MVC pattern. The MVC pattern is useful in things like web servers, where MVC adds flexibility. The controller acts as a mediator between the database and the user interface, and it does so in such an abstract way that either one can be easily changed (eg. the "view", which normally outputs HTML, could be easily changed to a different "view" which outputs a PDF or even plain text, all this without having to touch the controller or the model at all). However, I'm not seeing the advantages of the MVC pattern in an iPhone app. It provides a type of class design, but why is it better than some other class design? It's not like the input and output formats of the app need to be changed on the fly (which is one advantage of a well-designed program using the MVC pattern).

  • Question about documentation & interface inheritance

    If I have interface Foo that extends interface Bar, I'm wondering if there's a way for Foo to add more documentation to one of Bar's methods.
    For example, if I have:
    public interface Foo {
      * The "stuff" that gets done by this method should be more properly defined in the implementing class.
      void doStuff();
    public interface Bar extends Foo {
    }Is there any way for me to specify for Bar to override the doc on the doStuff() method inherited from Foo (such that it might read something like "The doStuff() method of all implementers of Bar should [behave in x manner]")?
    I realize I'm probably not articulating myself totally clearly, so let me know if I need to shed light on anything.
    Thanks!
    Edited by: Caryy on Nov 30, 2010 4:06 PM

    jverd wrote:
    I think you're allowed to declare an identical doStuff() method in Bar and give it its own documentation. It won't just get concatenated on to the supertype's doc, but the javadoc tool might generate a link to the parent method like it does when a class overrides or implement a method.Wow... >_< I thought I tried that and failed before asking this question, but it appears that you are correct (I must have typo'd or something)! Thanks for the fast reply and sorry for the n00b question....

  • Another question about query execution speed.

    I know I should normally start with posting the query but my question will take a little different direction, so here is the deal:
    We have an Apex application, there is a query on one of the pages that for certain users takes quite long, lets say 1min to 2 min, depending on how many records the query returns. The actual query varies depedning on some security settings and other parameters on the page - it's constructed by pl/sql function returning sql.
    By querying v$sql I get the exact sql run by the user for who the query takes long time to execute.
    Then I run that same sql statemt in Toad and it always takes 2 seconds to execute. For the user executing the same sql from Apex takes consistently 50-100 sec. My Toad is set to return up to 10,000 records and the query returns less than 500.
    Can somebody help me make some sense of this?
    George

    Hi there
    geo2 wrote:
    We have an Apex application, there is a query on one of the pages that for certain users takes quite long, lets say 1min to 2 min, depending on how many records the query returns. The actual query varies depedning on some security settings and other parameters on the page - it's constructed by pl/sql function returning sql.To render a page, Apex does much some more stuff than just run the query. For instance, depending on the type of pagination you have enabled it needs to get the total number of rows to display "x to y of z" (or to display the message "more than nnn rows found"). Have you enabled debugging in Apex to be sure that most of the waiting time is spent on that query?
    By querying v$sql I get the exact sql run by the user for who the query takes long time to execute.
    Then I run that same sql statemt in Toad and it always takes 2 seconds to execute. For the user executing the same sql from Apex takes consistently 50-100 sec. My Toad is set to return up to 10,000 records and the query returns less than 500.Does Toad takes only 2 seconds to retrieve all rows or just to get the first top rows?
    Luis

  • The simplest question about query in multimedia

    Hi i write in command line
    DECLARE
    score DOUBLE PRECISION;
    myimage SI_StillImage;
    myotherimage SI_StillImage;
    myAvgColor SI_AverageColor;
    BEGIN
    SELECT fotka1 INTO myimage FROM fotkiord WHERE fotkaid1=71;
    myAvgColor := NEW SI_AverageColor(myimage);
    SELECT fotka1 INTO myotherimage FROM fotkiord
    WHERE fotkaid1=72;
    score := myAvgColor.SI_Score(myotherimage);
    DBMS_OUTPUT.PUT_LINE('Score is ' || score);
    END;
    and I get from script output
    anonymous block completed
    Where i can find the real output of my query ??

    ok i answerd my own question
    create or replace
    PROCEDURE "PROC2"
    pod_id IN fotkiord.fotkaid1%type,
    pod1_id IN fotkiord.fotkaid1%type)
    IS
    score DOUBLE PRECISION;
    myimage SI_StillImage;
    myotherimage SI_StillImage;
    myAvgColor SI_AverageColor;
    BEGIN
    SELECT fotka1 INTO myimage FROM fotkiord WHERE fotkaid1= pod_id;
    myAvgColor := NEW SI_AverageColor(myimage);
    SELECT fotka1 INTO myotherimage FROM fotkiord
    WHERE fotkaid1= pod1_id;
    score := myAvgColor.SI_Score(myotherimage);
    DBMS_OUTPUT.PUT_LINE('Score is ' || score);
    END ;

  • General question about query

    Hi,
       You create a InfoCube, with aggregate been performed in it, now you write a query for that cube, how will you Identify a query with a cube, which has aggregate performed in it, is there a way to find it?
    Please let me know, if you dont understand the question.
    Thanks.
    will reward points.

    Hi,
    The fact that a query uses an aggregate to fetch the data from is transparent on the Bex front-end. If you want to check if a query is fethcing data from the cube or its aggregates, execute the query in RSRT with the Debug options set for aggregates.
    Hope this helps...

  • Question about methods in a class that implements Runnable

    I have a class that contains methods that are called by other classes. I wanted it to run in its own thread (to free up the SWT GUI thread because it appeared to be blocking the GUI thread). So, I had it implement Runnable, made a run method that just waits for the thread to be stopped:
    while (StopTheThread == false)
    try
    Thread.sleep(10);
    catch (InterruptedException e)
    //System.out.println("here");
    (the thread is started in the class constructor)
    I assumed that the other methods in this class would be running in the thread and would thus not block when called, but it appears the SWT GUI thread is still blocked. Is my assumption wrong?

    powerdroid wrote:
    Oh, excellent. Thank you for this explanation. So, if the run method calls any other method in the class, those are run in the new thread, but any time a method is called from another class, it runs on the calling class' thread. Correct?Yes.
    This will work fine, in that I can have the run method do all the necessary calling of the other methods, but how can I get return values back to the original (to know the results of the process run in the new thread)?Easy: use higher-level classes than thread. Specifically those found in java.util.concurrent:
    public class MyCallable implements Callable<Foo> {
      public Foo call() {
        return SomeClass.doExpensiveCalculation();
    ExecutorService executor = Executors.newFixedThreadPool();
    Future<Foo> future = executor.submit(new MyCallable());
    // do some other stuff
    Foo result = future.get(); // get will wait until MyCallable is finished or return the value immediately when it is already done.

  • Basic question about querying georaster tables

    hello all
    i have a table with georaster column containing georeferenced images covering large area. can i query the table to get an image covering any user given cooordinates . the user given coordinates can span more than one image in the table. is this possible
    thanks

    Hi,
    Yes this is possible to operate with several GeoRaster images in one or several tables. But before this you should create specific GeoRaster metadata structure to join those separate images. You can find information about this procedure in GeoRaster documentation.
    Regards,
    Andrejus

  • Question about constructors and inheritance

    Hello:
    I have these classes:
    public class TIntP4
        protected int val=0;
        public TIntP4(){val=0;}
        public TIntP4(int var)throws Exception
            if(var<0){throw new Exception("TIntP4: value must be positive: "+var);}
            val=var;
        public TIntP4(String var)throws Exception
            this(Integer.parseInt(var));
        public String toString()
            return val+"";
    public class TVF extends TIntP4
    }Using those clases, if I try to compile this:
    TVF  inst=new TVF("12");I get a compiler error: TVF(String) constructor can not be found. I wonder why constructor is not inherited, or if there is a way to avoid this problem without having to add the constructor to the subclass:
    public class TVF extends TIntP4
         public TVF (String var)throws Exception
              super(var);
    }Thanks!!

    I guess that it would not help adding the default constructor:
    public class TVF extends TIntP4
         public TVF ()
               super();
         public TVF (String var)throws Exception
              super(var);
    }The point is that if I had in my super class 4 constructors, should I implement them all in the subclass although I just call the super class constructors?
    Thanks again!

  • Hi,all I have a permission question about midp's httpconnection class

    Connection conn=Connector.open("http://www.sina.com.cn");
                   HttpConnection hc=(HttpConnection)conn;
                   int len = (int)hc.getLength();
                   byte[] b=new byte[len];
                   hc.openInputStream().read(b);
                   hc.close();
                   g.drawString(new String(b),0,0,0);
    this is my code, in function startApp()
    the result of the execute is that the screen prompt me a question:
    is it ok to use airtime?
    and the execption is :
    java.lang.SecurityException: Application not authorized to access the restricted API
         at com.sun.midp.security.SecurityToken.checkForPermission(+331)
         at com.sun.midp.security.SecurityToken.checkForPermission(+15)
         at com.sun.midp.midletsuite.MIDletSuiteImpl.checkForPermission(+20)
         at com.sun.midp.midletsuite.MIDletSuiteImpl.checkForPermission(+13)
         at com.sun.midp.io.ConnectionBaseAdapter.checkForPermission(+67)
         at com.sun.midp.io.j2me.http.Protocol.checkForPermission(+17)
         at com.sun.midp.io.ConnectionBaseAdapter.openPrim(+6)
         at javax.microedition.io.Connector.openPrim(+121)
         at javax.microedition.io.Connector.open(+15)
         at javax.microedition.io.Connector.open(+6)
         at javax.microedition.io.Connector.open(+5)
         at com.ipanel.j2me.test.TestCanvas.paint(+5)
         at javax.microedition.lcdui.Canvas.callPaint(+80)
         at javax.microedition.lcdui.Display.repaint(+77)
         at javax.microedition.lcdui.Display.registerNewCurrent(+237)
         at javax.microedition.lcdui.Display.access$400(+6)
         at javax.microedition.lcdui.Display$DisplayAccessor.foregroundNotify(+46)
         at javax.microedition.lcdui.Display$DisplayManagerImpl.notifyWantsForeground(+152)
         at javax.microedition.lcdui.Display$DisplayManagerImpl.access$100(+6)
         at javax.microedition.lcdui.Display.setCurrentImpl(+98)
         at javax.microedition.lcdui.Display.setCurrent(+29)
         at com.ipanel.j2me.test.Test.startApp(+16)
         at javax.microedition.midlet.MIDletProxy.startApp(+7)
         at com.sun.midp.midlet.Scheduler.schedule(+270)
         at com.sun.midp.main.CommandProcessor.run(+141)
         at com.sun.midp.main.CommandProcessor.dispatch(+49)
         at com.sun.midp.main.CommandProcessor.perform(+27)
         at com.sun.midp.main.Main.main(+171)
    i need to help... thanks

    You need to add permissions for some APIs in the JAD file.
    Ex. Add following line in your JAD (Java Archieve Descriptor) of your application.
    MIDlet-Permissions-Opt: javax.microedition.io.Connector.http
    Multiple permissions are to be separated with comma.
    Onkar

  • Question about emailing within iPhoto '11

    Hi -
    I emailed (so I thought) some photos from within iPhoto using Share > Email. But the email does not show up in my Sent Folder in Mail.
    Is this correct? How can I verify that I actually sent the email?
    Thanks
    MtD

    i REALLY LIKED mailing from iphoto, but inadvertantly changed the mailer to my email acct.  (i was asked if i wanted to change, and i did).
    HOW DO I GET THE ORIGINAL IPHOTO MAILER BACK.
    when i try to share a photo now, it just opens up MY mailer with the photo attached.
    CAN YOU HELP ME??? what's the original setting in preferences???
    THANK YOU !
    liz

  • Questions about these two IO classes....

    1)
    OutputStreamWriter
    An OutputStreamWriter is a bridge from character streams to byte streams: Characters written to it are encoded into bytes using a specified charset.
    i dont understand. Converting characters into bytes is understandable, but what does it mean by "using specified charset"?? I mean, isn't that the other way around?? ie, you convert bytes into characters using a specified charset??
    2)
    BufferedWriter, BufferedWhatEver...
    What does that makes code cleaner, when OutputStreamWriter and PrintWriter have basically same methods as they do??
    3)
    For top efficiency, consider wrapping an OutputStreamWriter within a BufferedWriter so as to avoid frequent converter invocations. For example:
    Writer out
    = new BufferedWriter(new OutputStreamWriter(System.out));
    What does it mean by "to avoid frequent converter invocations"?
    thanks for any responses.

    so, what is "buffering" then?
    I dont understand the explanation... lower code
    invocation??
    maybe in a plainer sentence will help??
    so sorry for not understand it.The following is not necessarily accurate in every technical detail, but it's close enough to demonstrate the principles.
    Let's say I'm going to write 10 bytes. I can do this: stream.write(b0);
    stream.write(b1);
    stream.write(b9);Each of those will cause stream to acces whatever native code it uses which will cause an I/O operation to happen at the hardware level--it will write a byte to the disk controller. It will do this once for every byte.
    Doing that physical I/O carries an overhead. The time taken to actually get the one byte written may be vastly overshadowed by the time taken to access the controller.
    You wouldn't want to establish a connection to a web server, read a byte, close the connection, establish antoher connection, read a byte, et.c. ... right?
    Now, instead, if I put the bytes in an array and call something like bufStream.write(arr, fromByteZero, tenBytes); then I make one call to the stream, it makes one call to the disk controller, pays the overhead cost only once, and writes all ten bytes.
    So instead of 10*overhead + 10*byte_write_time I pay 1*overhead + 10*byte_write_time

  • Question about casting and inheritances

    Hi everyone!
    I have a class dog which extends the class animal. Apart from that, there is a method called dogsFarm which returns a collection of animals (this method corresponds to another class, let's say farm). I can't touch the inside of that method since I just have the interface but I need a collection of dogs instead of a collection of animals. I tried to cast:
    Collection<dog> dogs = (collection<dog>) dogsFarm();But it says that it cannot cast that. Is it any way to solve this without having to change the method?
    Thanks

    Strictly speaking if the method returns a Collection<Animal>, then no amount of casting will turn it into a Collection<Dog> while still being type safe.
    The problem is that a Collection<Animal> could contain a Cat and if you cast it to a Collection<Dog>, it would contain an invalid value.
    You could use raw types (i.e. simply "Collection") to "forget" the generic type information and provide new one after that, but that's just an ugly hack that provides no real check.
    You could also use Collections.checkedCollection() to provide explicit checks.
    You can combine those two techniques to get code that's still ugly, but does at least some error checking:
    Collection rawFarm = dogFarm();
    Collection<Dog> = Collections.checkedCollection(rawFarm, Dog.class);

Maybe you are looking for

  • Max no of threads

    Is there such a thing as a max number of threads in a midp j2me application. My application, which makes extensive use of threads is suffering from hanging, where is shouldn't. How do I remedy this? Thanks. Pier.

  • Balances in negative.

    Some of the IC assets,liabilities accounts is showing negative balance. Means credit balance in asset and debit balance in liabilities. Insuch case we need to transfer the only negative balances do contra asset or liabilities accounts. Howto achieve

  • PERNR search help in ABAP Web Dynpro

    All, I wish to add a search help based on PERNR into my web dynpro application. I have used the code: *create a range table   lt_range_table = wd_this->m_handler->create_range_table( i_typename = 'ZEMP_SEL' ). *add a new field to range table   wd_thi

  • Restoring from 9.2.0.5 DB to 9.2.0.8

    I have a Production database running 9.2.0.5. I also a TEST and DEV database - running 9.2.0.5 and 9.2.0.8 (the 9.2.0.8 database in DEV was upgraded recently but no one has had the time to test it out) Now I have to duplicate my PROD (9.2.0.5) databa

  • Af:selectOneRadio : spacing between radio button and it's text

    Hi All, JDev 11.1.1.6 I want to put some space between two radio buttons (between two af:selectItem) say some 10px. <af:panelGroupLayout layout="horizontal" id="pgl9"> <af:outputText value="1. New mobile phone connection" inlineStyle="font-size: 12px