How to Store java.util.Map object using JPA

Hi
I have a cache where the underlying object is just a map (HashMap for example).
I'd like to create a JPA backing store for this cache.
Is there a way to do that, or can JPA only store objects that are JPA annotated?
Thanks
Edited by: mesocyclone on Dec 11, 2008 4:22 PM

Hi,
I believe that the objects that the Map contains would need to be JPA annotated.
--Tom                                                                                                                                                                                               

Similar Messages

  • How to Split java.util.Set object into multiple objects?

    Hi All,
    I'm having a collection of items in a Set. Assume that i'm having 10,000 items in Set A.
    Now i like to split the Set into multiple Set or Array such as each set or array consist of 100 records. i.e whenever
    i get more items i want to split them into mutiple set or array.
    Is there is any Java Api doesn't this function? or any other way to achieve this?
    Thanks,
    J.Kathir

    Iterate through them, placing them into different new collections.
    It may be easier to add the Set to a List, and then call sublist() a few times on the resulting List.

  • Java.util.Map to as object

    Hi,
    I want to get java.util.Map object returned from server-side
    on the client-side. I don't know which flex data-type should I use
    for that. I tried Array but it dint help. Someone plz help...
    Thanks in advance,
    Cheree

    You can use a for-in ActionScript loop to examine any
    ActionScript Object:
    for(var i:String in someObject) {
    trace( i+" = "+someObject
    Within the loop, i assumes the name of all the public
    properties in the given object.

  • JPA - Columns to java.util.Map

    I need to map the columns of a DB table into a java.util.Map object.
    Any idea about how to implement this feature?
    These are the columns of my table:
       | ID | Value01 | Value02 | Value03 | ... | ValueN |I'd like to obtain a bean like this:
    public class MyBean {
      private String ID;
      private Map values;
    }I thought I could extend java.util.Map and redefine the get(Object) and put(Object, Object) methods
    (I did something like this in java 1.4) but I can't figure it out in 1.5 with JPA

    >
    hi i have the following method,when i click my button am geting this error java.lang.String cannot be cast to java.util.Map
    >
    And that is correct - you can't do that cast. Which is what this code is trying to do.
    >
    (Map)actionEvent.getComponent().getAttributes().get("test")
    >
    Ask yourself what object is supposed to be the 'Map' in that line of code?
    Is it 'actionEvent', 'getComponent()' or 'getAttributes()'?
    My guess is that it is the 'getAttributes' that returns a map. Which means you need to cast
    actionEvent.getComponent().getAttributes()as a Map. Which means you need to put that entire thing in parentheses so that the cast is performed on it. And then you have to put THAT entire thing in parentheses so you can call the 'get' method on it.
    So this is the 'Map'
    (Map) (actionEvent.getComponent().getAttributes())And this calls the Maps 'get' method
    ( (Map) (actionEvent.getComponent().getAttributes()) ).get("test")If you broke the line into pieces and stored each piece in its own variable you would see it. These object types may not be right but should give you the idea.
    //( (Map) (actionEvent.getComponent().getAttributes()).get("test") ).get("test")
    MyComponent myComponent = (MyComponent) actionEvent.getComponent();
    Map myMap = (Map) myComponent.getAttributes();
    myMap.get("test");

  • How to Store word doc in oracle  using java

    hi
    toall
    can any one tell me how to store word doc in oracle9i using java
    bye

    Please refer to
    http://www.databasejournal.com/features/oracle/article.php/3305771

  • Java.util.Map type return in webservice method

    Wonder, how we can return a java.util.Map type from a webservice deployed on a
    weblogic 7.x environment..
    any input is appreciated.
    -Girish

    Thanks Michael. it helps.
    -Girish
    "Michael Wooten" <[email protected]> wrote:
    >
    Hi Girish,
    By definition, a Java object used as a input parameter (or return type)
    of a web
    service operation, must has a no-arg constructor in order for a Java-based
    Web
    Service Stack to serialize/deserialize it to/from XML. java.util.Map
    is an interface,
    so it does not meet this requirement :-)
    If your web service operation is just trying to return (or accept) a
    hash map
    of "arbitrary complex types", I recommend that you consider switching
    this to
    be an "array of arrays of specific complex types". The reason I say this
    is because,
    it allows even non-Java consumers to look at the <schema> elements in
    your web
    services' WSDL, and figure out all the possible "arbitrary complex types"
    that
    might be in this array. If you envision the consumer getting a box, where
    it can
    literally contain anything, you can probably see how much more code they
    would
    need to write, than if they knew the the box contained a box of these,
    and a box
    of these, and so on, and so on.
    Basically, all the "old school" type-safety rules still apply to web
    services
    computing. If you want web services with descent performance metrics,
    you're probably
    going to want to keep a lot of the "old school, distributed computing"
    practices
    in mind, when you design your stuff :-)
    That said, WLS 7.0 SP1 does not currently have a "built-in" HashMap codec.
    But,
    you could create one using the information at:
    http://edocs.bea.com/wls/docs70/webserv/customdata.html#1054435
    Regards,
    Mike Wooten
    "girish" <[email protected]> wrote:
    Wonder, how we can return a java.util.Map type from a webservice deployed
    on a
    weblogic 7.x environment..
    any input is appreciated.
    -Girish

  • Servlet java.util.Map Help

    It's been a while since I have written any code and I am having an issue getting back into it.
    I am currently working on creating servlet to pass info from all my forms to my business logic. However, I am having an issue with getting the data. This may be a topic for a different forum, but I figured I would ask here.
    I tested out the servlet with the getParameter() method, and I can get the values. However, when I try to use the java.util.Map, I get blank values.
    I think the issue may be that I forgot how to use the Map object. Here is my code:
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet CalCartController</title>");
    out.println("</head>");
    out.println("<body>");
    for (int i = 0; i < formParamsMap.size(); i++) {
    Map.Entry entry = (Map.Entry) keyValuePairs.next();
    String key = (String)entry.getKey();
    String value = (String)entry.getValue();
    out.println(value);
    out.println("<h1>Servlet CalCartController </h1>");
    out.println("</body>");
    out.println("</html>");

    hacktorious wrote:
    OK, so if I replace the loop with the following:
    String firstName = (String)formParamsMap.get("firstName");
    out.println(firstName);
    this gives a blank result.If firstName is an actual parameter, it's probably throwing an exception, and you're swallowing it or otherwise not seeing it. I would expect a ClassCastException if the map contained "firstName".

  • Error: java.util.map can not be inherited with different arguments

    Hi,
    I am getting following error while building the source code.
    C:\venus\src\com\martquest\messaging\msgio\MqMessageIOObjectCarrier.java:36: java.util.Map cannot be inherited with different arguments: <> and <java.lang.Object,java.lang.Object>
    [javac] public class MqMessageIOObjectCarrier extends Properties implements IMqMessageIOObjectCarrier
    What should I do to resolve this issue?
    Thanks
    Prachi

    Hi,
    I am getting following error while building the
    source code.whose source code? If it's yours, you'd better look at where you are defining and using Map. The error code tells you exactly what's wrong.

  • Java.util.map in a jar?

    My applet works on Netscape 6.1 presumably because the java.util.map class has capabilities that I'm using in my applet that isn't in other versions of java.util.map. Since I want to make my applet cross platform, is there any way to include java.util.map in my jar file so that people can use that version instead? Thanks.
    Denise

    Denise,
    I think that will break your license agreement with Sun, so you probably don't want to do that, right? ;)
    I think you should try to figure out what the exact cause of your problem is. Off hand, it almost sounds like your applet uses v1.3 api, but your still using the old <Applet> html tag and not the new <Object> tag. Is this right?
    -Ron

  • Message Mapping - java.util.Map

    Hi There
    I would like to know if there is any way, using java.util.Map map; to get the "data type" field name in a UDF? Passing a constant with the field name would not be practical.. I'm looking for a object oriented process to use in all my mappings.
    Also where could I look for the methods I can use in the map trace object?
    Regards,
    Jan

    But I'm still missing the field name..
    Let say I have a message mapping going from Field ACB to Field QAZ and a UDF called CheckLen.
    In my UDF I'm looking at the incoming field and if it's length is correct. if not I'm writing an entry into a table stating there was an incorrect field but what I can't get is the the field name so I can write to the table "Invalid length on field ACB" The only way to get this field name value is by passing a constant of "ACB" to the UDF and using that. But we have hundreds of MMs so implementing this would be much more difficult than a OOP way..

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

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

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

  • Exposing java.util.Map data as RequiredModelMBean

    I'm trying to expose java.util.Map data but I can't quite figure how.
    I'd like the management interface to look like it has an attribute that is actually the key of the map.
    For example, calling:
    mBeanServer.getAttribute(new ObjectName("nomojomofo:type=mapBean"), "fubar");
    would get its data from the target object as:
    aMap.get("fubar");
    Edited by: nomojomofo on Oct 9, 2007 5:31 PM

    You can write a DynamicMBean for that:
    http://weblogs.java.net/blog/emcmanus/archive/2006/11/a_real_example.html
    However you should be aware that most JMX consoles do not expect that the MBeanInfo of a given MBean can change over time.
    If the content of your Map is fixed - you won't have any problem.
    If it can change over time, you might consider exposing the Map as a single attribute,
    for instance, as a CompositeData.
    You might also be interested in this article:
    http://blogs.sun.com/jmxetc/entry/dynamicmbeans%2C_modelmbeans%2C_and_pojos...
    Hope this helps,
    -- daniel
    http://blogs.sun.com/jmxetc

  • Java.util.Map and  java.util.HashMap samples

    Hi.
    Please, I need some code samples of java.util.Map and java.util.HashMap interfaces. I have problems to retreive objects in the map.
    Cheers,
    Cata

    Try the tutorial:
    http://java.sun.com/docs/books/tutorial/collections/index.html

  • Java.util.Map and null key

    Hi,
    For information, according to the implementation, it is possible to put and get a null key when using a map.
    The null key can be added and retrieved when using a HashMap, an exception is thrown for a TreeMap.

    The documentation for java.util.Map states:
    Some map implementations have restrictions on the keys and values they may contain. For example, some implementations prohibit null keys and values, and some have restrictions on the types of their keys. Attempting to insert an ineligible key or value throws an unchecked exception, typically NullPointerException or ClassCastException.The documentation for java.util.TreeMap.put() states:
    Throws:
    NullPointerException - if the specified key is null and this map uses natural ordering, or its comparator does not permit null keysSo a Map generally may or may not support null keys and/or values and the decision is up to the concrete implementation. TreeMap states that it doesn't support null keys, unless a Comparator is used that permits null keys.

  • BEA error: deleteTaskAttributes(int,java.util.Map)

    Hello,
    I have installed OIM 9100 on BEA with an Oracle Database.
    I got the following error message after starting OIM:
    <08.07.2008 11.07 Uhr CEST> <Warning> <EJB> <BEA-012034> <The Remote interface method: 'public abstract void com.thortec
    h.xl.scheduler.interfaces.SchedulerController.deleteTaskAttributes(int,java.util.Map) throws com.thortech.xl.scheduler.e
    xception.SchedulerGenericException,java.rmi.RemoteException' in EJB 'SchedulerController' contains a parameter of type:
    'java.util.Map' which is not Serializable. Though the EJB 'SchedulerController' has call-by-reference set to false, this
    parameter is not Serializable and hence will be passed by reference. A parameter can be passed using call-by-value only
    if the parameter type is Serializable.>
    Can anybody help me or tell me what it means?
    Thank you,
    Matthias

    BEA Weblogic normally throws a ton of these errors as it seems like OIM's ideas on what should be passed by reference and what should be passed by value does not play well with Weblogic.
    I have been told to ignore these warnings.
    Good luck
    /M

Maybe you are looking for

  • Raising of CONTROL_FLUSH_ERROR during background execution of RBDMIDOC

    Hi I run program RBDMIDOC in the background job for automatic transport of data. I’m sure that RBDMIDOC supports  background executing, but background job is canceled  with runtime error “RAISE_EXCEPTION” and following description: Exception conditio

  • Multiple text boxes on one slide

    Hi all- I want the user to enter their First Name, Last Name, then User ID on one slide. I am using 3 text boxes. 1.  I want the cursor to be positioned in the First Name text box when the user gets to that slide. 2   I am not validating their inform

  • XI Error when transfering invoice from MM - XI - SRM.

    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> - <!--  Call Inbound Proxy   --> - <SAP:Trace xmlns:SAP="http://sap.com/xi/XI/Message/30">   <Trace level="1" type="B" name="CL_XMS_HTTP_HANDLER-HANDLE_REQUEST" /> - <!--  *********************

  • Can barcodes be created using Report Builder

    Hi Gurus, Can anybody please tell me How to create Barcodes using Oracle.. It's Urgent.. Please Help.. Regards Swati

  • How do I manage songs already on my ipod

    I want to take songe off of my ipod shuffle and cannot figure out how to connect to the device rather than my library