GetField() NoSuchFieldException

Hello,
I'm learning Java and I have problem with Reflection. My code:
import java.lang.reflect.Field;
public class TestReflection {
     public String name = new String("John");
     public TestReflection () {
          Field param = this.getClass().getField("name");
When I try to execute this code, I get NoSuchFiedlException. I must be doing something wrong...
Thanks,
Rok

rokpok wrote:
I distinguish beetween compilation and execution. I didn't express myself in the right way. When I try to compile the code this is what I get:
C:\Users\rok.kreslin.notebook\workspace\Ucenje\src>javac TestReflection.java
TestReflection.java:9: unreported exception java.lang.NoSuchFieldException; must be caught or declared to be thrown
Field parameter = this.getClass().getField("name");
^
1 error
This is much more informative. It's telling you that "getField()" can throw a checked exception, so you either need to catch it (surround it with a try/catch block) or declare it (use a "throws" clause in the method declaration). Do you know what checked exceptions are?

Similar Messages

  • How to Test "NoSuchFieldException" Using if {} else{}?

    I have a line of code in a loop:
    Field column = DownloadChildClassColumns.class.getDeclaredField(id);The above code throws "NoSuchFieldException" for certain "id"s in the "getDeclaredField" method. If it happens, I have to get the Field from another class:
    Field column = DownloadParentClassColumns.class.getDeclaredField(id);How do I test using if {...} else {...}. That is, if a certain Field is unavailable in one class, then get that Field in another class?
    Thank you for your guidance.

    JavaLaptop wrote:
    I might not get the idea. Sorry, my head is as hard as a stone sometimes.
    If I use the "getDeclaredField( id )", I still can get the "NoSuchFieldException".
    My problem is "how" to test out if certain Field is not in one class then I go to another class to get it.Do the second test in the catch clause dependant on the first e.g.
    Field field = null;
    try  {
        field = class1.getField("fieldName");
      } catch(NoSuchFieldException ex) {
         try {
           field.class2.getField("fieldName");
          } catch(NoSuchFieldException ex2) {
             log.error("No such field as fieldName");
             throw new IllegalStateException("fileName not found in either class");
       }

  • Java.lang.Class- getFields() results in JVM crash when called through JNI

    From a C++ application, I use Invocation APIs to create a JVM and call some Java methods using JNI
    I get a crash in jvm.dll with EXCEPTION_ACCESS_VIOLATION
    when I try to call "getFields" method of java.lang.Class in order to get the Fields of the java class
    This method call, should return a java/lang/reflect/Fields[] on success
    I am able to get the method ID of this method by using pEnv->GetMethodID(..)
    However, when I call this method using CallObjectMethod(..), HotSpt JVM crashes with access violation with the dump given below.
    Any clues on how to debug and find the problem?
    Or has anyone tried getting the fields of a Java class from C++ by calling reflection APIs uing JNI?
    Thanks in advance!
    Sample code
    jclass testerClass = pEnv->FindClass("com/test/Tester");
    jmethodID cid = pEnv->GetMethodID(testerClass,"<init>","()V");
    if(NULL == cid)
    pEnv->ExceptionDescribe();
    jobject testerObject = pEnv->NewObjectV(testerClass, mid);
    jmethodID mid = pEnv->GetMethodID(testerClass, "getClass",
                             "()Ljava/lang/Class;");
    jobject clsObj = (jobject)pEnv->CallObjectMethod(testerObject, mid);
    pEnv->ExceptionDescribe();
    jclass      jCls = pEnv->GetObjectClass(clsObj);
    jmethodID midGetFields = pEnv->GetMethodID(jCls, "getFields",
                                            "()[Ljava/lang/reflect/Field;");
    jobjectArray jobjArray = (jobjectArray)pEnv->CallObjectMethod(testerObject, midGetFields);
    pEnv->ExceptionDescribe();
    Crash dump
    Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x809E69F
    Function=JVM_FindSignal+0x11505
    Library=D:\Java\j2re1.4.2_03\bin\client\jvm.dll
    Current Java thread:
         at java.lang.Class.privateGetDeclaredFields(Unknown Source)
         at java.lang.Class.privateGetPublicFields(Unknown Source)
         at java.lang.Class.getFields(Unknown Source)
    Dynamic libraries:
    0x00400000 - 0x00419000      E:\SC\SC12.1\SCApplications\SNMP\Bin\JNITester.exe
    0x77F50000 - 0x77FF7000      C:\WINDOWS\System32\ntdll.dll
    0x77E60000 - 0x77F46000      C:\WINDOWS\system32\kernel32.dll
    0x10000000 - 0x10023000      E:\SC\SC12.1\SCApplications\SNMP\Bin\JniUtils.dll
    0x00320000 - 0x00332000      E:\SnmpIpmNativeTestDriver\MTFStubHelper.dll
    0x00340000 - 0x0035B000      E:\SnmpIpmNativeTestDriver\MTFXMLFileAPI.dll
    0x12000000 - 0x122B1000      e:\sc\sc12.1\bin\xerces-c_2_2_0D.dll
    0x77DD0000 - 0x77E5D000      C:\WINDOWS\system32\ADVAPI32.dll
    0x78000000 - 0x78086000      C:\WINDOWS\system32\RPCRT4.dll
    0x10200000 - 0x1026C000      e:\sc\sc12.1\bin\MSVCRTD.dll
    0x102A0000 - 0x102B7000      e:\sc\sc12.1\bin\MSVCIRTD.dll
    0x5F800000 - 0x5F8E9000      e:\sc\sc12.1\bin\MFC42uD.DLL
    0x77C70000 - 0x77CB0000      C:\WINDOWS\system32\GDI32.dll
    0x77D40000 - 0x77DCC000      C:\WINDOWS\system32\USER32.dll
    0x5F700000 - 0x5F746000      e:\sc\sc12.1\bin\MFCD42uD.DLL
    0x5F500000 - 0x5F5C6000      e:\sc\sc12.1\bin\MFCO42uD.DLL
    0x10480000 - 0x104FE000      e:\sc\sc12.1\bin\MSVCP60D.dll
    0x15020000 - 0x15042000      e:\sc\sc12.1\bin\SCTraceLib.dll
    0x6D510000 - 0x6D58D000      C:\WINDOWS\System32\dbghelp.dll
    0x77C10000 - 0x77C63000      C:\WINDOWS\system32\msvcrt.dll
    0x77C00000 - 0x77C07000      C:\WINDOWS\system32\VERSION.dll
    0x00360000 - 0x0037D000      e:\sc\sc12.1\bin\SCFileManager.dll
    0x76BF0000 - 0x76BFB000      C:\WINDOWS\System32\PSAPI.DLL
    0x00420000 - 0x00580000      e:\sc\sc12.1\bin\BctCoreCL.dll
    0x5D920000 - 0x5D929000      C:\WINDOWS\System32\RPCNS4.dll
    0x71B20000 - 0x71B31000      C:\WINDOWS\system32\MPR.dll
    0x71C20000 - 0x71C6E000      C:\WINDOWS\System32\NETAPI32.dll
    0x71AB0000 - 0x71AC5000      C:\WINDOWS\System32\WS2_32.dll
    0x71AA0000 - 0x71AA8000      C:\WINDOWS\System32\WS2HELP.dll
    0x15000000 - 0x15012000      e:\sc\sc12.1\bin\CTEventLog.dll
    0x773D0000 - 0x77BC2000      C:\WINDOWS\system32\SHELL32.dll
    0x70A70000 - 0x70AD4000      C:\WINDOWS\system32\SHLWAPI.dll
    0x771B0000 - 0x772D1000      C:\WINDOWS\system32\ole32.dll
    0x77120000 - 0x771AB000      C:\WINDOWS\system32\OLEAUT32.dll
    0x1F7A0000 - 0x1F7D6000      C:\WINDOWS\System32\ODBC32.dll
    0x77340000 - 0x773CB000      C:\WINDOWS\system32\COMCTL32.dll
    0x763B0000 - 0x763F5000      C:\WINDOWS\system32\comdlg32.dll
    0x08000000 - 0x08138000      D:\Java\j2re1.4.2_03\bin\client\jvm.dll
    0x76B40000 - 0x76B6C000      C:\WINDOWS\System32\WINMM.dll
    0x5FD00000 - 0x5FD0D000      C:\WINDOWS\System32\MFC42LOC.DLL
    0x71950000 - 0x71A34000      C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.10.0_x-ww_f7fb5805\comctl32.dll
    0x1F840000 - 0x1F857000      C:\WINDOWS\System32\odbcint.dll
    0x5DAC0000 - 0x5DAC7000      C:\WINDOWS\System32\rdpsnd.dll
    0x00FE0000 - 0x00FE7000      D:\Java\j2re1.4.2_03\bin\hpi.dll
    0x01000000 - 0x0100E000      D:\Java\j2re1.4.2_03\bin\verify.dll
    0x01010000 - 0x01029000      D:\Java\j2re1.4.2_03\bin\java.dll
    0x01030000 - 0x0103D000      D:\Java\j2re1.4.2_03\bin\zip.dll
    0x76C90000 - 0x76CB2000      C:\WINDOWS\system32\imagehlp.dll
    Heap at VM Abort:
    Heap
    def new generation total 576K, used 132K [0x15050000, 0x150f0000, 0x15530000)
    eden space 512K, 25% used [0x15050000, 0x15071250, 0x150d0000)
    from space 64K, 0% used [0x150d0000, 0x150d0000, 0x150e0000)
    to space 64K, 0% used [0x150e0000, 0x150e0000, 0x150f0000)
    tenured generation total 1408K, used 0K [0x15530000, 0x15690000, 0x19050000)
    the space 1408K, 0% used [0x15530000, 0x15530000, 0x15530200, 0x15690000)
    compacting perm gen total 4096K, used 964K [0x19050000, 0x19450000, 0x1d050000)
    the space 4096K, 23% used [0x19050000, 0x191410e0, 0x19141200, 0x19450000)
    Local Time = Wed Aug 25 21:06:44 2004
    Elapsed Time = 0
    # HotSpot Virtual Machine Error : EXCEPTION_ACCESS_VIOLATION
    # Error ID : 4F530E43505002EF
    # Please report this error at
    # http://java.sun.com/cgi-bin/bugreport.cgi
    # Java VM: Java HotSpot(TM) Client VM (1.4.2_03-b02 mixed mode)

    You are right, I tried getting the java.lang.Class reference for the com.test.Tester by calling getClass() on com.test.Tester
    And using this jclass reference for java.lang.Class, I tried getting the method ID of getFields and eventually the Field[]
    Thanks for the help
    I have some more questions.
    Assumption - Using JNI, I got the fields array of com.test.Tester and I am iterating through the fields
    1.Assuming that the Tester class had an Integer field say m_nIntVal, then once I get the jobject equivalent of this Field in C++.
    Now I need to get the type of the field (I call the method java.lang.reflect.getType() from JNI)
    This gives me a jclass reference to it's type i.e java.lang.Integer
    2.I need to get the name of this type i.e I want to get the name of the type in a string as "java.lang.Integer"
    For this, on the jclass reference of java.lang.Integer got in Step 1, I call getClass() from JNI (to get the java.lang.Class) and then getName()
    Now, for calling getClass(), I need a temporary object reference corresponding to the jclass of java.lang.Integer, The problem is that Integer does not have a default constructor, so my call to create the jobject fails.
    But, since I do not know that I am constructing an Integer (remember that is what I am trying to find out - getType), I cant pass any values to constructor
    Now, how do I go about creating a jobject of Integer, without knowing that I am constructing that, as this does not have a default constructor without parameters
    Also, I tried using AllocObject to get the jobject and then tried to get the method ID of getClass(). Even this failed
    3. If the com.test.Tester class had a primitive "int" field, say m_nPrimitiveInt
    for which java provides a Class representation, I am able to get the jclass reference to the type of m_nPrimitiveInt
    Now, how do I get the name of the type as "int" in a string?
    Forllowing a similar procedure like in Step 2 fails when I try to pass the jclass reference to the type of m_nPrimitiveInt to the GetMethodID
    with the error FATAL ERROR in native method: JNI received a class argument that is not a class
    Can you tell me what is the way out?
    Thanks in advance,
    Also, can I mail you with some doubts that I have? If its ok, please contact me at [email protected]

  • How to retain field formatting using this.getField

    I am pulling a phone number from a form field using this.getField("EmailAddress").value and inserting it into an email.  Once there, it loses it's formatting as a phone number and becomes a string if 10 digits again.  Is there a way to retain or recreate this formatting?

    Since a Format script doesn't change the underlying field value, just what gets displayed in the field, you'll have to add something that changes the underlying field value. You can use the Validate event for this and even use the same built-in code that's use by Acrobat to do the formatting. Begin by adding the following function to a document-level JavaScript:
    // Function in a document-level JavaScript
    function phoneValidate() {
          // Use Acrobat built-in formatting routine for phone numbers
          AFSpecial_Format(2);
    and call this function with the following custom Validate script:
    // Custom Validate script
    phoneValidate();
    The AFSpecial_Format() function takes what is entered into the field, generates a formatted string, and set event.value to the string. When this is done in a Validate script, it changes the field value.

  • Missing method getField() in sapjco3

    Hi,
    in sapjco 2.x i using this:
    JCO.Field field = table.getField("TEXT")
    what can i use in 3.x?
    JCoField field = table.getField("Text") 
    does't work because there is no method getField in JCoRecord

    Hi
    Have look at this [Migration gudie|https://websmp207.sap-ag.de/~sapidb/011000358700000730362009D/SAPJCo_MigrationGuide_2.x_3.0_EN.pdf]
    Regards

  • Class/Reflection/getFields()

    Dear Friends
    Can any one help me to find a solution for the following problem:
    I am using a class with inner class and table model. I wanted to get the list of all attributes from both inner and outer classes. All attributes are declared public. I used the Class / Reflection and managed to get the list of attribute in the inner class as shown below. The following code neatly listed all the attributes in the inner class but not the one in outer class.
    Class c = classA.innerClassA_.getClass() ;
    Try
    Field[] fa = c.getFields() ;
    For(int i=0; i<fa.length; i++)
    Field f = fa;
    System.out.println(f) ;
    catch(SecurityException se)
    Thanks in anticipation,
    sunder

    You'll need to start with listing all inner classes by using the method:
    getDeclaredClasses() in java.lang.Class.
    In your case:
    classA.class.getDeclaredClasses();Where I presume assume that classA is the class that holds the internal classes.
    This will give you an array of all your internal classes.
    Given this you can simply find all declared fields in you inner classes.
    Hope this was to some help

  • This.getField error in app.Mail script

    I am having trouble with an app.Mail script I have created in a Lifecycle form.  If I place a this.getField("field_name") line in the script Acrobat Javascript debugger states that the this.getField is not a function.  Also the this.path line returns as undefined in the email message body if bypass the this.getField line.  Perhaps I am mixing up Javascript script and Lifecycle scripting?  If so what needs to be changed for Lifecycle?  I know the app.mail script works without the var lines, but once I add those in is when the problems pop up.  Script listed below.  Thanks!
    var cMyMsg = this.path
    var Sub = this.getField("Field_Name").value;
    app.mailMsg({bUI: true, cTo: "[email protected], cSubject: Sub, cMsg: cMyMsg});

    Hi,
    Your script is written using Acrobat JavaScript, whereas because you are working in LiveCycle Designer you need to make the script compatible with the LiveCycle Designer form JavaScript.
    The code could be changed to this which works in LiveCycle Designer
    var cMyMsg = event.target.path
    // Assuming the Field_Name field is in the same subform as the button to run the code
    var Sub = Field_Name.rawValue;
    app.mailMsg({bUI: true, cTo: "[email protected]", cSubject: Sub, cMsg: cMyMsg});
    Hope this helps
    Malcolm

  • EJB deployment to WL7.0 ends with error NoSuchFieldException

    After several successful deployment of an EJB to WL7.0 server, I
    started to get
    WLS70:There is a mismatch between the bean code and generated
    code.<EJB name>. Please rerun ejbc on the bean code.The error was
    java.lang.NoSuchFieldException
    This is very strange, since nothing was changed in the setup of
    weblogic, and not much was changed in the bean itself.
    I saw some posting about WL6.1 suggesting to remove folders named
    tmp_EJBxxx, but this seems not relevant to WL7.0, since I cannot find
    these folders.
    I tried these to two different WL7.0 servers, with the same behavior:
    at the beginning, deployment is fine, and then it stops to work. Of
    course, I tried to clean all and re-deploy, but nothing works :(
    Any idea what shall I do?
    Should I remove other folders in WL7.0 ;) ?
    Thanks, Aviv.

    Hi Aviv,
    After you update your EJB, you should always rerun ejbc before
    redeploying. Did you do that?
    - Matt
    Aviv Siegel wrote:
    After several successful deployment of an EJB to WL7.0 server, I
    started to get
    WLS70:There is a mismatch between the bean code and generated
    code.<EJB name>. Please rerun ejbc on the bean code.The error was
    java.lang.NoSuchFieldException
    This is very strange, since nothing was changed in the setup of
    weblogic, and not much was changed in the bean itself.
    I saw some posting about WL6.1 suggesting to remove folders named
    tmp_EJBxxx, but this seems not relevant to WL7.0, since I cannot find
    these folders.
    I tried these to two different WL7.0 servers, with the same behavior:
    at the beginning, deployment is fine, and then it stops to work. Of
    course, I tried to clean all and re-deploy, but nothing works :(
    Any idea what shall I do?
    Should I remove other folders in WL7.0 ;) ?
    Thanks, Aviv.

  • ObjectInputStream.GetFields: Useful in readObject()?

    The following is an excerpt from the User Guide description of ObjectInputStream.GetField class (http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/input.doc2.html):
    ��Using readFields to access the serializable fields does not change the format of the stream. It only provides an alternate API to access the values which does not require the class to have the corresponding non-transient and non-static fields for each named serializable field. The serializable fields are those declared using serialPersistentFields or if it is not declared the non-transient and non-static fields of the object. When the stream is read the available serializable fields are those written to the stream when the object was serialized. If the class that wrote the stream is a different version not all fields will correspond to the serializable fields of the current class. The available fields can be retrieved from the ObjectStreamClass of the GetField object.�
    Based on this description, I assumed that this API could be used within an object�s readObject() method to retrieve fields with names/types that differ from the current object. This assumption appears to be false.
    In my tests with 1.3 and 1.4.01, the serialization code makes a number of comparisons between the class being deserialized, and the local (vm loaded) version of the class. These comparisons include class cast compatibility, serialVersionUID compatibility, and field name/type compatibility. If any of the test fail, an appropriate exception is thrown. These tests are performed before the call is made to the object�s readObject method. (In 1.4_01, these tests are performed by ObjectSteamClass.initNonProxy().)
    In the following example, Foo (version 2) cannot successfully deserialized Foo (version 1). The serialization mechanism with throw a field type mismatch on �field1� before calling readObject(). Foo (version 2b) will fail as well. This time, because of an incompatible serialVersionUID.
    // Version 1
    public class Foo implements Serializable
        private static final long serialVersionUID = 1L;
        protected int field1 = 123;
    // Version 2
    public class Foo implements Serializable
        private static final long serialVersionUID = 1L;
        protected String field1 = 123;
        private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
            ObjectInputStream.GetField fields = in.readFields();
            field1 = Integer.toString(fields.get(�field1�,  0));
    // Version 2b
    public class Foo implements Serializable
        private static final long serialVersionUID = 2L;
        protected String field1 = 123;
        private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
            ObjectInputStream.GetField fields = in.readFields();
            field1 = Integer.toString(fields.get(�field1�,  0));
    }It appears ObjectInputStream.readFields() cannot be used within readObject() as the documentation describes. Am I missing something?
    Thanks, Craig.

    Oops. In version 2 and 2b, the following line:
    protected String field1 = 123;should read:
    protected String field1 = "123";

  • Internal Exception: java.lang.NoSuchFieldException

    i have a java app that displays data from a table called MasterScrip using jpa. i wish to add an extra field to my table but, when i add an extra field named 'change' to my database table MasterScrip i get following exception, when i remove the field, the app works fine
    Exception [EclipseLink-0] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.IntegrityException
    Descriptor Exceptions:
    Exception [EclipseLink-59] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DescriptorException
    Exception Description: The instance variable [change] is not defined in the domain class [entity.MasterScrip], or it is not accessible.
    Internal Exception: java.lang.NoSuchFieldException: change
    Mapping: org.eclipse.persistence.mappings.DirectToFieldMapping[change-->StockCommodityDB.MasterScrip.Change]
    Descriptor: RelationalDescriptor(entity.MasterScrip --> [DatabaseTable(StockCommodityDB.MasterScrip)])
    //stack trace with ejbTransactionRolledBackException
    entity MasterScrip.java:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package entity;
    import java.io.Serializable;
    import java.util.Collection;
    import javax.persistence.Basic;
    import javax.persistence.CascadeType;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.ManyToOne;
    import javax.persistence.NamedQueries;
    import javax.persistence.NamedQuery;
    import javax.persistence.OneToMany;
    import javax.persistence.Table;
    import javax.validation.constraints.NotNull;
    import javax.validation.constraints.Size;
    import javax.xml.bind.annotation.XmlRootElement;
    import javax.xml.bind.annotation.XmlTransient;
    * @author root
    @Entity
    @Table(name = "MasterScrip", catalog = "StockCommodityDB", schema = "")
    @XmlRootElement
    @NamedQueries({
    @NamedQuery(name = "MasterScrip.findAll", query = "SELECT m FROM MasterScrip m"),
    @NamedQuery(name = "MasterScrip.findByScripID", query = "SELECT m FROM MasterScrip m WHERE m.scripID = :scripID"),
    @NamedQuery(name = "MasterScrip.findByScripSymbol", query = "SELECT m FROM MasterScrip m WHERE m.scripSymbol = :scripSymbol"),
    @NamedQuery(name = "MasterScrip.findByType", query = "SELECT m FROM MasterScrip m WHERE m.type = :type"),
    @NamedQuery(name = "MasterScrip.findByCompanyName", query = "SELECT m FROM MasterScrip m WHERE m.companyName = :companyName"),
    @NamedQuery(name = "MasterScrip.findByLastTradedPrice", query = "SELECT m FROM MasterScrip m WHERE m.lastTradedPrice = :lastTradedPrice"),
    @NamedQuery(name = "MasterScrip.findByLastTradedQuantity", query = "SELECT m FROM MasterScrip m WHERE m.lastTradedQuantity = :lastTradedQuantity"),
    @NamedQuery(name = "MasterScrip.findByOpenPrice", query = "SELECT m FROM MasterScrip m WHERE m.openPrice = :openPrice"),
    @NamedQuery(name = "MasterScrip.findByHighPrice", query = "SELECT m FROM MasterScrip m WHERE m.highPrice = :highPrice"),
    @NamedQuery(name = "MasterScrip.findByLowPrice", query = "SELECT m FROM MasterScrip m WHERE m.lowPrice = :lowPrice"),
    @NamedQuery(name = "MasterScrip.findByTotalTradedQuantity", query = "SELECT m FROM MasterScrip m WHERE m.totalTradedQuantity = :totalTradedQuantity"),
    @NamedQuery(name = "MasterScrip.findByVolume", query = "SELECT m FROM MasterScrip m WHERE m.volume = :volume"),
    @NamedQuery(name = "MasterScrip.findByExchange", query = "SELECT m FROM MasterScrip m WHERE m.exchange = :exchange"),
    @NamedQuery(name = "MasterScrip.findByBrokerageCharge", query = "SELECT m FROM MasterScrip m WHERE m.brokerageCharge = :brokerageCharge"),
    @NamedQuery(name = "MasterScrip.findByPreviousClose", query = "SELECT m FROM MasterScrip m WHERE m.previousClose = :previousClose"),
    @NamedQuery(name = "MasterScrip.findByChange", query = "SELECT m FROM MasterScrip m WHERE m.change = :change")})
    public class MasterScrip implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "ScripID", nullable = false)
    private Integer scripID;
    @Size(max = 15)
    @Column(name = "ScripSymbol", length = 15)
    private String scripSymbol;
    @Size(max = 10)
    @Column(name = "Type", length = 10)
    private String type;
    @Size(max = 50)
    @Column(name = "CompanyName", length = 50)
    private String companyName;
    // @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "LastTradedPrice", precision = 22)
    private Double lastTradedPrice;
    @Column(name = "LastTradedQuantity")
    private Integer lastTradedQuantity;
    @Column(name = "OpenPrice", precision = 22)
    private Double openPrice;
    @Column(name = "HighPrice", precision = 22)
    private Double highPrice;
    @Column(name = "LowPrice", precision = 22)
    private Double lowPrice;
    @Column(name = "TotalTradedQuantity")
    private Integer totalTradedQuantity;
    @Column(name = "Volume")
    private Integer volume;
    @Size(max = 30)
    @Column(name = "Exchange", length = 30)
    private String exchange;
    @Column(name = "BrokerageCharge", precision = 22)
    private Double brokerageCharge;
    @Column(name = "PreviousClose", precision = 22)
    private Double previousClose;
    @Column(name = "Change", precision = 22)
    private Double change;
    @JoinColumn(name = "CommoditySubCategoryID", referencedColumnName = "CommoditySubCategoryID")
    @ManyToOne(fetch = FetchType.EAGER)
    private CommoditySubCategoryMaster commoditySubCategoryID;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "scripID", fetch = FetchType.EAGER)
    private Collection<UserStock> userStockCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "scripID", fetch = FetchType.EAGER)
    private Collection<UserTrack> userTrackCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "scripID", fetch = FetchType.EAGER)
    private Collection<OrderStock> orderStockCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "scripID", fetch = FetchType.EAGER)
    private Collection<TradeStock> tradeStockCollection;
    public MasterScrip() {
    public MasterScrip(Integer scripID) {
    this.scripID = scripID;
    public Integer getScripID() {
    return scripID;
    public void setScripID(Integer scripID) {
    this.scripID = scripID;
    public String getScripSymbol() {
    return scripSymbol;
    public void setScripSymbol(String scripSymbol) {
    this.scripSymbol = scripSymbol;
    public String getType() {
    return type;
    public void setType(String type) {
    this.type = type;
    public String getCompanyName() {
    return companyName;
    public void setCompanyName(String companyName) {
    this.companyName = companyName;
    public Double getLastTradedPrice() {
    return lastTradedPrice;
    public void setLastTradedPrice(Double lastTradedPrice) {
    this.lastTradedPrice = lastTradedPrice;
    public Integer getLastTradedQuantity() {
    return lastTradedQuantity;
    public void setLastTradedQuantity(Integer lastTradedQuantity) {
    this.lastTradedQuantity = lastTradedQuantity;
    public Double getOpenPrice() {
    return openPrice;
    public void setOpenPrice(Double openPrice) {
    this.openPrice = openPrice;
    public Double getHighPrice() {
    return highPrice;
    public void setHighPrice(Double highPrice) {
    this.highPrice = highPrice;
    public Double getLowPrice() {
    return lowPrice;
    public void setLowPrice(Double lowPrice) {
    this.lowPrice = lowPrice;
    public Integer getTotalTradedQuantity() {
    return totalTradedQuantity;
    public void setTotalTradedQuantity(Integer totalTradedQuantity) {
    this.totalTradedQuantity = totalTradedQuantity;
    public Integer getVolume() {
    return volume;
    public void setVolume(Integer volume) {
    this.volume = volume;
    public String getExchange() {
    return exchange;
    public void setExchange(String exchange) {
    this.exchange = exchange;
    public Double getBrokerageCharge() {
    return brokerageCharge;
    public void setBrokerageCharge(Double brokerageCharge) {
    this.brokerageCharge = brokerageCharge;
    public Double getPreviousClose() {
    return previousClose;
    public void setPreviousClose(Double previousClose) {
    this.previousClose = previousClose;
    public Double getChange() {
    return change;
    public void setChange(Double change) {
    this.change = change;
    public CommoditySubCategoryMaster getCommoditySubCategoryID() {
    return commoditySubCategoryID;
    public void setCommoditySubCategoryID(CommoditySubCategoryMaster commoditySubCategoryID) {
    this.commoditySubCategoryID = commoditySubCategoryID;
    @XmlTransient
    public Collection<UserStock> getUserStockCollection() {
    return userStockCollection;
    public void setUserStockCollection(Collection<UserStock> userStockCollection) {
    this.userStockCollection = userStockCollection;
    @XmlTransient
    public Collection<UserTrack> getUserTrackCollection() {
    return userTrackCollection;
    public void setUserTrackCollection(Collection<UserTrack> userTrackCollection) {
    this.userTrackCollection = userTrackCollection;
    @XmlTransient
    public Collection<OrderStock> getOrderStockCollection() {
    return orderStockCollection;
    public void setOrderStockCollection(Collection<OrderStock> orderStockCollection) {
    this.orderStockCollection = orderStockCollection;
    @XmlTransient
    public Collection<TradeStock> getTradeStockCollection() {
    return tradeStockCollection;
    public void setTradeStockCollection(Collection<TradeStock> tradeStockCollection) {
    this.tradeStockCollection = tradeStockCollection;
    @Override
    public int hashCode() {
    int hash = 0;
    hash += (scripID != null ? scripID.hashCode() : 0);
    return hash;
    @Override
    public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof MasterScrip)) {
    return false;
    MasterScrip other = (MasterScrip) object;
    if ((this.scripID == null && other.scripID != null) || (this.scripID != null && !this.scripID.equals(other.scripID))) {
    return false;
    return true;
    @Override
    public String toString() {
    return "entity.MasterScrip[ scripID=" + scripID + " ]";
    what could be the reason of this exception? how do i solve it?

    i cleaned and built the app and redeployed it. now i am getting the following exception:
    Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Change, CompanyName, Exchange, HighPrice, LastTradedPrice, LastTradedQuantity, L' at line 1
    Error Code: 1064
    Call: SELECT ScripID, BrokerageCharge, Change, CompanyName, Exchange, HighPrice, LastTradedPrice, LastTradedQuantity, LowPrice, OpenPrice, PreviousClose, ScripSymbol, TotalTradedQuantity, Type, Volume, CommoditySubCategoryID FROM StockCommodityDB.MasterScrip
    Query: ReadAllQuery(name="MasterScrip.findAll" referenceClass=MasterScrip sql="SELECT ScripID, BrokerageCharge, Change, CompanyName, Exchange, HighPrice, LastTradedPrice, LastTradedQuantity, LowPrice, OpenPrice, PreviousClose, ScripSymbol, TotalTradedQuantity, Type, Volume, CommoditySubCategoryID FROM StockCommodityDB.MasterScrip")
         at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)
    where am i wrong?

  • Change of field order obtained from getFields()

    I use getFields() method of 'Class' to obtain the fields of a class. Fields returned from method are in order they are declared but according to documentation this order is not guaranteed.
    The elements in the array returned are not sorted and are not in any particular order.When may this order change? At each time the class is loaded or according to version of virtual machine or compiler?..

    Fields returned from method are in order they are declared but according to documentation this order is not guaranteed.So they are not in any particular order.
    When may this order change?Any time at all.
    At each time the class is loaded or according to version of virtual machine or compiler?.It's not specified. So don't rely on any ordering.
    That's what the Javadoc is telling you. Listen and learn.

  • Using this.getField to hide multiple buttons...

    Hello all,
    I'm a relative newb to scipting, but I'm sure there's not better way to learn than jumping in at the deep end! Anyway, I'm putting some script into a pdf I want to hide multiple buttins using this.getField... Is it possible to have script like
    this.getField("buttons1").display=display.hidden
    this.getField("buttons2").display=display.hidden
    this.getField("buttons3").display=display.hidden
    this.getField("buttons4").display=display.hidden
    etc..?
    My only problem is that I have this scipt (only a bit longer) under a button and it only seems to execute the first line, then the rest of the script (which includes some OCG visibility) doesn't

    As George said, you need to check the javascript debugger to see if there are any messages. If your buttons are not named exactly as you have it in the script (e.g. "buttons 1", "Buttons1", "button1") then it will give you an error, and won't process any of the following code. The debugger will tell you what the error is and on which line it occurred.

  • Expression.get("PRODUCT_ID").getField("PRODUCT_NAME").like("Freezer")

    Hi! All,
    In ServiceRequests Table Product_Id is a an attribute, and Product Information like Product Name , Product Description is in Products Tale. The relation between theses is Product_Id column in ServiceRequests Table.
    Getting the Product_Id , I need to get the Names of the Produts that have Freezer in the first word of their name.
    for that I'm doing,
    ReadAllQuery raq= new ReadAllQuery(ServiceRequests.class);
    raq.setReferenceClass(ServiceRequests.class);
    ExpressionBuilder builder = new ExpressionBuilder();
    raq.setSelectionCriteria(builder.get("PRODUCT_ID").getField("PRODUCT_NAME").like("Freezer"));
    // raq.setSelectionCriteria( builder.getField("PRODUCT_ID").greaterThan(100));
    Vector servicelist = (Vector) session.executeQuery(raq);
    I'm getting : TopLink Exception -- 6015 Invalid Query key[Product_Id]
    Can some one tell me where I am doing wrong, or was it a wrong way to do to get the desired result?
    Thanking you in Advance,
    Samba

    I didn't notice before you're using get(..) and getField(..). If you've got your classes mapped you shouldn't have to use getField(..). By capturing your object-relational mappings in TopLink, you enable querying based on the attributes of objects instead of the database columns. This helps decouple your code from the data model. For example, I can write the following expression given the classes below:
    ExpressionBuilder employee = new ExpressionBuilder();
    Expression where = employee.get("address").get("streetName").equal("Main");
    emp = (Emp)session.readObject(Emp.class, where);
    public class Emp{
       long empId;
       Address address;
    public class Address {
       long addressId;
       String streetName;
    ...See how I reference the address attribute of an Emp and put a constraint on the streetName? This expression will result in a SQL join based on the table reference info I provided in the TopLink one-to-one mapping between Emp and Address. I don't use the column names in my query at all. The are encapsulated in the TopLink mappings.
    I think this is similar to the problem you're facing. Does this help?
    --Shaun                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Class.getFields order difference between 1.3 and 1,4

    Hi,
    in java1.3 Class.getFields returns a Field[] which is sorted in the order of initialization but in 1.4 this order is gone.
    I tried this in both IBM and Sun 1.3/1.4 jdks on Windows.
    How can I obtain this order info?

    Hi,
    in java1.3 Class.getFields returns a Field[] which is
    sorted in the order of initialization but in 1.4 this
    order is gone.
    I tried this in both IBM and Sun 1.3/1.4 jdks on
    Windows.As already pointed out, "order of initialisation" doesn't seem to make any sense here. So I'll assume from here on you're talking about order of declaration in a source file.
    In both 1.3 and 1.4 the API documentation clearly states that "The elements in the array returned are not sorted and are not in any particular order."
    If you have written code that relies on the ordering from 1.3, then you just learned a valuable lesson - for portability, code to the specs and not to other observed behaviours - under the spec it would be perfectly acceptable for another vendor to provide a 1.3 JRE that doesn't order the returned array in the same way that Sun and IBM apparently do.
    >
    How can I obtain this order info?Parse the sourcefile.

  • NoSuchFieldException Error deploying EJB

    I am porting a WL 4.5.1 application to WL 6.1. I have ported the EJB's from 1.0
    to 1.1. I am using "cold" deployment as I am just trying to get this to run.
    I can deploy some of them but I get the following exception when I try to deploy
    others:
    Unable to deploy EJB: mrswap.VideoHome from mrswap_video.jar:
    There is a mismatch between the bean code and generated code.mrswap.VideoHome
    .      Please rerun ejbc on the bean code.The error was java.lang.NoSuchFieldException
         at java.lang.Class.getField0(Native Method)
         at java.lang.Class.getDeclaredField(Class.java:1113)
         at weblogic.ejb20.deployer.ClientDrivenBeanInfoImpl.setMDField(ClientDrivenBeanInfoImpl.java:650)
         at weblogic.ejb20.deployer.ClientDrivenBeanInfoImpl.setMethodDescriptors(ClientDrivenBeanInfoImpl.java:722)
         at weblogic.ejb20.deployer.ClientDrivenBeanInfoImpl.deploy(ClientDrivenBeanInfoImpl.java:813)
         at weblogic.ejb20.deployer.Deployer.deployDescriptor(Deployer.java:1226)

    Additional info:
    I have rerun EJBC and that does not help. I can not tell any difference between
    the EJB's that deploy and the ones that do not, there are all entity beans, all
    have finder methods, etc.
    Has anyone has seen this before?
    Thanks,
    Randy
    "Randy" <[email protected]> wrote:
    >
    I am porting a WL 4.5.1 application to WL 6.1. I have ported the EJB's
    from 1.0
    to 1.1. I am using "cold" deployment as I am just trying to get this
    to run.
    I can deploy some of them but I get the following exception when I try
    to deploy
    others:
    Unable to deploy EJB: mrswap.VideoHome from mrswap_video.jar:
    There is a mismatch between the bean code and generated code.mrswap.VideoHome
    .      Please rerun ejbc on the bean code.The error was java.lang.NoSuchFieldException
         at java.lang.Class.getField0(Native Method)
         at java.lang.Class.getDeclaredField(Class.java:1113)
         at weblogic.ejb20.deployer.ClientDrivenBeanInfoImpl.setMDField(ClientDrivenBeanInfoImpl.java:650)
         at weblogic.ejb20.deployer.ClientDrivenBeanInfoImpl.setMethodDescriptors(ClientDrivenBeanInfoImpl.java:722)
         at weblogic.ejb20.deployer.ClientDrivenBeanInfoImpl.deploy(ClientDrivenBeanInfoImpl.java:813)
         at weblogic.ejb20.deployer.Deployer.deployDescriptor(Deployer.java:1226)

Maybe you are looking for

  • Batch determination while prd. ord. confirmation

    Dear Experts,      We have got batch management system for raw material in our organisation.  Here, we are selecting the batch number to the material while releasing the production order ( order will not be relesed if we are not selecting batch numbe

  • Open Hub export to ASCII file

    Is it possible to export infoprovider data through open hub to an ASCII formatted file? How would we do that in BI 7.0?

  • Change to 10.1.3 CustomSerializer

    Hi, i wrote a customserializer for a custom class which extends ArrayList that just delegates the work to org.apache.soap.encoding.soapenc.ArraySerializer. Since changing to JDev 10.1.3 customs serializer must implement oracle.webservices.databinding

  • External harddrive issue

    I recently moved all my iTunes files to an external hard drive by consolidating them there. I then removed my iTunes folder. Later my computer crashed and I had to reinstall iTunes. Now the information shows up in my iTunes but it can't find the file

  • No Overlap Container Component

    I want to write a component that will allow children to be added, but will prevent them from overlapping. I have played around with a few collision detection type things, but I haven't been successful. I'm posting this to see if I can get some feedba