JPA and Entities without setter methods

Hello,
maybe a stupid question: I have an entity without a setter methods in order to make it immutable after creation. I�ve written all JPA annotations on method level - here on the getter method. I�ve got the error msg that the setter is required. It is possible to annotate fields without the setter method?
Thx,
Thilko

I've got a number of immutable Entity Beans working, but I annotated them all on the field level, not the method level. I couldn't figure out why anyone would want to annotate them as methods, especially given the fact that JPA still sucks with dates. I store all my dates as longs, and use the getters and setters to convert back and forth from java.util.Date objects. If I annotated the methods, I assume I'd either have to find some way to store Date objects, or have my getters and setters deal with longs.
It feels a little weird declaring a field private and then annotating it so that external code can change it, but it works fine. Additionally, you only have to write half as many annotations.
Try annotating fields rather than methods (of course, you have to do each Entity Bean all the same way, no mixing) and see how it works for you.

Similar Messages

  • How do I change my security questions and answers without setting up a new account. I can't remember the answers to the questions that they ask.

    How do I change my security questions and answers without setting up a new account. I can't remember the answers to the questions that they ask.

    1. See my User Tip for some help: Some Solutions for Resetting Forgotten Security Questions: Apple Support Communities.
    2. Here are two different but direct methods:
        a. Send Apple an email request at: Apple - Support - iTunes Store - Contact Us.
        b. Call Apple Support in your country: Customer Service: Contacting Apple for support
            and service.
    3. For other queries about Apple ID see Frequently asked questions about Apple ID.
    4. Rescue email address and how to reset Apple ID security questions
    5. For online assistance use Apple - Support - Express Lane

  • Reflection and the field.set method

    OK, I've made 2 classes, a ClearParent and ClearChild (which extends ClearParent). I'd like to have a "clear" method on the parent which dynamically sets all the fields to null. I'd like to be able to have any child that inherits from the parent be able to call clear and dynamically have all it's fields set to null.
    Part of the restriction that I'm facing is that the fields are Objects (Integer) but the getter and setter methods take and return types (int). So I can't just loop through the Methods and call the setters with null.
    I'd like to be able to loop through the fields and call set for all the fields with the parent class.
    I'm inserting the code that I have for the parent and child classes at the end. Basically, the problem that I'm seeing is that if I do a
    this.getClass().getName()
    from the parent (when clear is called from the child) it shows me the child name ("ClearChild"). But when I try to do the
    field.set(this, null)
    it tells me this:
    Class ClearParent can not access a member of class
    ClearChild with modifiers "private"
    How come when I get the name it tells me that it's the child but when I pass "this" to the set method, it says that it's the parent?
    Any one know what's going on here? Is there anyway that I can have the parent set all the fields to null?
    Thanks in advance.
    Here's the code:
    ClearParent
    import java.lang.reflect.*;
    public class ClearParent {
        public boolean clear() {
            try {
                System.out.println(this.getClass().getName());
                Field[] fields = this.getClass().getDeclaredFields();
                Field   field;
                for (int i = 0; i < fields.length; i++) {
                    field = fields;
    field.set(this, null);
    } catch (Exception e) {
    e.printStackTrace();
    return true;
    ClearChild
    public class ClearChild extends ClearParent {
    private Float f;
    public ClearChild() {
    super();
    public float getF() {
    if (f == null) {
    return 0;
    return f.floatValue();
    public void setF(float f) {
    this.f = new Float(f);
    public static void main (String[] args) throws Exception {
    ClearChild cc = new ClearChild();
    cc.setF(23);
    cc.clear();
    System.out.println("cc.getF: " + cc.getF());

    It is an instance of ClearChild that is being used so
    that class name is ClearChild. However, the method
    exists in the parent class and thus cannot act upon a
    private field of another class (even if it happens to
    be a subclass).Ahh...makes sense.
    Why don't you just override clear in the child?We were trying to avoid this because we run into problems in the past of people adding fields to the class, but not adding to the clear, and things not being cleared properly.
    I talked it over with the guys here and they have no problem making the fields protected instead of private. If it's protected, then the parent has access to it and my sample code works.
    Thanks for your help KPSeal!
    Jes

  • How to call setter Method of ActionScript class with in a Flex Application

    Hi
    I have Action class as shown :
    public class MyClass
    private var name:String 
    public function get name():String {
        return _initialCount;
    public function set name(name:String):void {
        name = name;
    Now please let me know how can i access this Action class under my Flex Application and call the setter Method of it to set the value for the name .
    For example on entering some data in a TextInput and  click of a submit Button , on to the Event Listener , i want to call the set name method of my ActionScript class .
    Please share your ideas on this .

    Thanks  Gordon for your resonse .
    Say for example my Action class is like this :
    public class MyClass
    private var name:String 
    public function get name():String {
        return name;
    public function set name(name:String):void {
        name = name;
    This is inside the MXML
    I know this way we can do it
    public var myclass:MyClass = new MyClass();
    myclass.name="Kiran";
    Now my query is can we do in this way also ??
    myclass.set name(SomeTextInput.text);
    Please share your views on this , waiting for your replies .
    Thanks in advance .

  • Setter method not getitng called in the custom tag

    Hi,
    I have written a custom tag and I have declared an attribute in the tld file and have specified the setter method for the same in the java tag file but that setter method is not getting called...for rest of the attributes, the methods are getting called and not just for one!! any idea what could be the problem....
    Regards
    Deepak Saini

    Do you have a getter method to match that property?
    Post some example code - what does your tld define for this property, and what get/set methods have you defined for it?

  • "no setter method for ..."

              I got 7 same problems in compilation of different JSPs when I built petstore in
              the wls6.1.
              [execon] Error: translation of /productdetails.jsp failed: weblogic.servlet.jsp.JspException:
              (li
              ne 7): Error in using tag library uri='/WEB-INF/tlds/taglib.tld' prefix='j2ee':
              There is no setter m
              ethod for property 'numItems', for Tag class 'com.sun.j2ee.blueprints.petstore.taglib.list.SearchLis
              tTag'
              [execon] Error: translation of /product.jsp failed: weblogic.servlet.jsp.JspException:
              (line 10):
              Error in using tag library uri='/WEB-INF/tlds/taglib.tld' prefix='j2ee': There
              is no setter method
              for property 'numItems', for Tag class 'com.sun.j2ee.blueprints.petstore.taglib.list.SearchListTag
              I checked SearchListTag and there is setter method in there.
              Could anyone have solutions on them?
              Thanks.
              Jim
              

    I have found this same problem in weblogic 8.1 and the only work around I saw was to have the same class in getter and setter both. ie if your tag is setting a String then when you write 'getter' it should return a String object.
              See if that works out !
              goodluck
              Vijay
              Message was edited by:
              vjdeshmukh

  • AP and Expenses without Accounting Entry Template

    Hello,
    Is there a way to use AP and Travel and Expense without setting up an accounting entry template?
    This templates asks 35 accounts but more then half of them are for functionality taht we won't use so we don't really see the point in setting it up...
    In case we have to set it up, is there an explenation somewhere of which account in the list is used for which functionality? The 'fundamentals' PeopleBook doesn't seem to provide us with a lot of info.
    Regards,
    Stijn

    Hi,
    Make the VAT condition statistical and post the G/L using the accrual key concept.
    Here it is not necessary the Customer G/L should hit.
    Regards,
    Saju.S

  • JAXB is not generating the setter method for my tag

    Hi,
    I am generating java classes form my .xsd file using JAXB.
    The xsd definition has defnes a Form as a sequence of FormElement, where FormElement is a choice of graphical components like text etc. Form can have 0 or unbounded elements of typeFormElement
    Example
    <xs:element ref="sswfm:FormElement" minOccurs="0" maxOccurs="unbounded"/>
    It is creating the getter method for this tag like this-
    java.util.List getFormElement();
    but does not create setter method, namely, setFormElements which I would like to use when marshalling from swing to XML.
    If i remove the maxOccurs="unbounded, it is creating the setter method for this tag.But i want to keep this tag as it it and needs the setter method also.
    What should i do? Has one tried this before. HELP if you can
    Thank you in advance.

    Hi RavindraKshirsagar,
    We have a problem like you faced. Our requirement is that, we need to generate dynamically the PERSON element in our javabean.
    <xs:element name='SERVICE_REQUESTER'>
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref='ORGANIZATION' />
                        <xs:element ref='PERSON' maxOccurs='unbounded' />
                   </xs:sequence>
              </xs:complexType>
         </xs:element>For this maxOccurs, as JAXB is not generating any Setter Method. As we need to get data dynamically from external application. If you could help us in handling this case dynamically, it will be well and good.
    Please send us the script / code asap.

  • I've jail break Iphone 3GS. i tried to restore setting (erasing all data and media) without connecting to computer/itunes. When it starts it freezes by showing apple logo only. what is the solution.

    i've jail break Iphone 3GS. i tried to restore setting (erasing all data and media) without connecting to computer/itunes. When it starts it freezes by showing apple logo only. what is the solution. please help me out. Here i don't have iphone service center too.

    Although not illegal, Apple discourages a user from modifying the iPhone OS in any manner, including "jailbreaking".  Apple feels so strongly about this that discussing methods to assist a user trying to either jailbreak or "unjailbreak" an iPhone are prohibited.

  • HT4859 I have an iPhone 5 and have just set up the iCloud for it. I also have an iPad with different content and I also want to connect it to iCloud. Will I lose everything that's on my iPad or iPhone or do they sync together without losing anything?

    I have an iPhone 5 and have just set up the iCloud for it. I also have an iPad with different content and I also want to connect it to iCloud. Will I lose everything that's on my iPad or iPhone or do they sync together without losing anything?

    The problem is that all services are bundled with your Apple ID ([email protected]):
    Your iCloud account (Mail, Contacts, Calendars, Reminders, Notes, Backups, etc.),
    also iTunes & App Store purchases (Music, Movies, TV Shows, etc.),
    and the iTunes Match services.
    (I guess that all your devices - yours and your wife's are connected to one iTunes library, right?)
    If you want that your wife gets her own iCloud account for Mail, Contacts, Calendars, etc. but gets also access to your media then you have two set up two things on her device:
    iCloud (Settings > iCloud) with her account (e.g. [email protected])
    and
    iTunes & App Stores (Settings > iTunes & App Stores) with your account (e.g. [email protected]).
    In this case she gets access to your library and could use the same iTunes Match account.
    (See also: Using one Apple ID for iCloud and a different Apple ID for Store Purchases http://support.apple.com/kb/HT4895)

  • Code for replacing 'get' and 'set' method

    Hi,
    I was a struts programmer but now i am a jsf programmer :-)
    I was able to do the following with struts but no with jsf...
    The following code in struts allowed me to have no 'get' and 'set' method in the javabean for a property (for example, the property 'name'):
    ValueStack valueStack =ActionContext.getContext().getValueStack();
    valueStack.set("name", "John");
    ActionContext.getContext().setValueStack(valueStack);In the jsp, using the corresponding label to retrieve the 'name' property, returned value 'John'.
    Is there something equivalent in jsf?

    Hi, see on here.There are solutions for JSF, JBoss Seam: [Solutions for Java, JSF, JBoss Seam and Flex|http://flextrick.blogspot.com/]

  • Why do we need get and set methods?

    It is considered good design practice to keep all class data private and
    provide get and set methods for accessing the data in a controlled
    manner.
    So, instead of directly accessing the class data, you use getter and setters.
    I do not really feel the need to use get and set methods.
    How does that achieve encapsulation when ultimately the class data is being exposed?

    A couple of reasons why to use get and set:
    1. For example you can set an int value for month, if a user sets this to somting
    higher than 12 (or 11 if it's zero based) you want to handle that by either
    throwing an exception or adding a year for every time it can be devided by 12.
    If you dont do it in set you'll have a whole bunch of methods that might need to
    correct the value before retreiving the eventual date.
    2. If for some reason you have security set up for certain values you can
    implement this in the get method. When this is done somewhere else you have
    a whole bunch of methods retreiving the info in other classes that need to check
    first. (a canGet method could allso be used). Another good reason to use get
    is when the information needs to be converted depending on the consumer
    calling the get method.
    3. If any logic in 1 or 2 changes you'll have a bunch of code to change.
    If you feel there is no need to implement any security, error handling (on
    compiling because get and set might throw something) or validation when
    setting/getting these values there is still the argument of readabillity.
    Eclipse has a feature that will generate getters and setters for you so it's not
    like there is a lot of extra typing involved.
    Got interupted whyle typig so sorry to repeat any answer given before.

  • I just bought my company boss's iphone 3gs and want to set it up in my PC without loosing the apps on it.

    I just bought my company boss's iphone 3gs and want to set it up in my PC without losing the apps & music already on  it.  I have  already got a library for my old iphone 3g and was wondering how to go about it. 
    cheers

    That's called stealing, plain & simple. Your boss(or anyone for that matter) does not have the right to distribute any content, for any reason. The SLA does not permit such. When you plug the phone into your computer, all iTunes content will be erased from the phone, as it should be. You want content, purchase your own.

  • Are there any settings in the options (or anywhere else) that I can use to set up an auto confirm and resend without having to manually click the 'resend' butto

    There is a certain website I use that I refresh frequently. Every time I do I get a pop up message labeled ‘Confirm’ with a question mark in it that says;
    “To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier."
    It only seems to be a problem with this one particular site. Are there any settings in the options (or anywhere else) that I can use to set up an auto confirm and resend without having to manually click the ‘resend’ button in the pop up window?

    Hi cor-el, Thanks for responding;
    I am accustomed to seeing this type of pop up on occasion and understand why they are necessary to prevent duplicating orders, payments, etc. I am not using a back button, I wanted to use an auto-refresh app to search for reservation openings on a certain web site and can not because this pop up requires me to manually push a button every time the page refreshes. I am resending the same information every time (a date range) via the POST form, so, was hoping there was a way to either disable, override, or set up and auto response so I can use the auto-refresh app. Your description of how to avoid the pop up didn't entirely make sense to me, but If I have to do a bunch of manual steps in between each refresh attempt it doesn't matter because I'm no better off.

  • My daughter received an I phone for Christmas and we set it up using my iTunes account.  She just received an iPad and wants to set up her own iTunes account.  How do we do that without lsing all of her content that she added to my iTunes account.

    My daughter received an I phone for Christmas and we set it up using my iTunes account.  She just received an iPad and wants to set up her own iTunes account.  How do we do that without losing all of her content that she added to my iTunes account. I have home sharing on my account.

    Welcome to the Apple Community.
    If she creates her own iTunes account she can't use any protected content purchased under another account. She can play unprotected content synced from an iTunes library on a computer, but she can only download content from the cloud that is purchased under her account.
    It's a pain I know, but the longer you put off the move, the worse the situation will become.

Maybe you are looking for

  • How do I convert a batch of pdf files to tiff

    I need to convert batches of 2000 multipage pdf files to a multipage tiff file with the same name as the original pdf

  • '$P_CRM' is undefined Error while opening Lookup field in Bulk edit form in CRM 2013

    Hi All, I am getting this strange error in MS CRM 2013 When I do bulk edit for any entity , I select 2-3 records and click on Edit , the Bulk edit form opens then whenever I clicks on any field which is lookup type It does not open , after debugging

  • Active Virus Shield

    I use active virus shield which is kaspersky but given away by AOL. If I have avs running when using Lightroom I get database errors (especially during image import). I try to remember to disable it but that isn't a very good solution. Is this a know

  • Mac recognizing artist, song name, etc.

    i'm trying to load up itunes on my wife's mac, i use a PC for myself. Don't know why, but the computer is not reading artist name, album, song name off of the cd's. Everything goes on to itunes as unidentified track 1, 2. 3 etc. Is there some setting

  • ADMT share domain local groups access denied

    Hi,  I have encountered strange behavior when migrating share with permissions. This is the situation: 1) We have migrated groups from source domain(these groups are used for defining access to shares, users are directly members of these, no nested g