Help with a design, using Java Persistence

I'm having a design issue, and I hope that someone can help.
I have a table called Item, and it essentially acts as a header table for a group of attributes for that item.
TABLE Item
.....id....................long
.....itemName.........varchar
.....StartDate........datetime
.....StopDate........datetime
If I can, I'd like to design a model that will allow for a dynamic number of attributes for any given ITEM.
I initially thought that it would be convenient to design the Attributes table like such:
TABLE Attribute
.....id....................long
.....itemID.............long (references Item.id)
.....attributeName....varchar
.....value...............?
.....StartDate.........datetime
.....StopDate.........datetime
My problem is the VALUE column. Attributes can be any given type, so this won't work if I want to enforce a data type.
I don't know where to go from here. I can create a table to include all attributes, but each attribute needs to have a date range.
Additionally, the history of the attributes must be retained; so, if I succeeded any given Attribute I would need to duplicate the
entire row (thus, all the other data that didn't change).
One thought was to create an Attribute table for each of the most common types, but that seems like a really bad idea:
TABLE AttributeLong
TABLE AttributeDateTime
TABLE AttributeVarchar
etc, etc ...
I should note that I'm using Java Persistence.

I agree with you 100%. Here is something I'm trying to get a grip on: there are a finite number of attributes per group, but the number of attribute groups can grow (maybe 20 sets max - but I just don't know yet).
I would need one table (Entity) for each set of attributes.
So, for instance, let's say I have:
Item1 is of kind KIND1 that has an attribute set of SET1
(ie, tables ITEM and SET1)
Item2 is of kind KIND2 that has an attribute set of SET2
(ie, tables ITEM and SET2)
I'd like to have my Item entity class set up like such:
myItem.getAttributeSet
instead of:
myItem.getAttributeSet1
myItem.getAttributeSet2
Since at given time I can extend my application (and add new entity classes to support a new table for SET3), I wanted to avoid changing Item. I can have getAttributeSet return an interface and then cast it, but that still requires changing Item to account for the new entities. Thus, I can't just drop in new "packages."
I want a flexible and extensible system., but maybe I'm over thinking/engineering this.

Similar Messages

  • Need help with ABAP coding using java

    Dear experts,
    I have used ABAP to code many reports/function modules.However as i know java quite well,i want to achieve the same using java.I have utilized JCO to retrieve information from RFC in this mission.
    However i realized that i had to code all things using ABAP and use java only as interface to connect to
    SAP fetch that module and display information on console.It was not that fun.
    I want that i should not Login to SAP but work only using java.
    I heard SAP Netweaver is a good choice.But i dont know much about it.Will i be able to develop reports only by java and how ?
    Plz suggest.

    hi,
    I hope that you already have the J2ME Toolkit and that your emulator works okay. In the toolkit you get several examples to show you how to program a MIDlet. One has to do with a HTTP client server connection. Also in the API documentation for the J2ME there is a Connector class that you used to set up this communication and in the description of this class it pretty thoroughly explains how to set up an HTTP protocol client.
    However, if you want to do some other kind of networking then you are pretty much out of luck, as the TCPIP socket protocol has not been fully implemented and is optional to the J2ME specifications, only the HTTP protocol is certain to be available. This means that mobile phone companies can add other networking functionality to their phone's java virtual machine if they feel like it. This is a bummer I know.
    I hope this helps.
    Cheers,
    Mark

  • Need help with Socket prog using Java wireless toolkit

    Hi, I am not able to communicate between client (Palm emulator) and server (Java on computer) using Java Wireless toolkit.
    Can anyone please tell me a site that shows an example. I have seen a bunch of examples but they all run by importing com.sun.kjava which seems to have vanished into thin air. So I cannot run them. Someone please show me some lines of code that will send just one character from client Palm emulator to server. thanks.
    Syed

    hi,
    I hope that you already have the J2ME Toolkit and that your emulator works okay. In the toolkit you get several examples to show you how to program a MIDlet. One has to do with a HTTP client server connection. Also in the API documentation for the J2ME there is a Connector class that you used to set up this communication and in the description of this class it pretty thoroughly explains how to set up an HTTP protocol client.
    However, if you want to do some other kind of networking then you are pretty much out of luck, as the TCPIP socket protocol has not been fully implemented and is optional to the J2ME specifications, only the HTTP protocol is certain to be available. This means that mobile phone companies can add other networking functionality to their phone's java virtual machine if they feel like it. This is a bummer I know.
    I hope this helps.
    Cheers,
    Mark

  • Need help with jsp that uses a java program

    Hi, sorry for my english but i am italian.
    I've got a problem: i use java builder and i have a java program(this program has got a main and includes libraries) about graphich on tree, this program visualizes these trees and makes operations on these.
    Now i must use JSP so that a client can see this program (this program is on the server) and can interact with it.
    I can't use applet.I must use only jsp.
    Who can tell me how can i start???
    Thanks.

    If you are not allowed to use an applet, then you are limited by what can be achieved with HTML in a browser.
    You would have to figure out how to render it with HTML, then program your jsp to write out this html programatically.

  • Database access design using java bean

    Hi,
    I am writing a JSP/servlet/Javabean based app. using MVC architecture.The database related logic is in java beans.
    I want a generalized class/bean that can form a connection , execute the passed query and return the results.Does any one has any URLs or sample code to explain how to do this using introspection?
    I would greatly appreciate any help as this design is very crucial for our application.
    Thanks -
    k

    Please check the Cameleon Open Source project at http://www.must.de/cameleon.html if ti fits your needs.

  • Help with swap images using rollovers

    I have a website created using DW CS5. Recently purchased FW CS5 to help with web graphics and design. I am trying to create a list of numbers that will swap with images. The intial page would simply be a list of numbers and 1 static image. Each number, when hovered will change the image with another. I've attempted this by first using DW and not having much success with FW either.
    If able to complete this using FW, is it possible to export the file for use in DW? Then insert into an AP Div?

    You're over-complicating it.
    Simply hit File>Save once you're done in photoshop.
    ian

  • Need help with class design

    I want to design and use one or more classes for a particular project I am working on.
    I need some advice hopefully from someone who has experience in this area. Basically,
    for this particular problem I have two database tables. I want the first class to
    represent the first database table and the second class to represent the second
    database table. An object of the first class will be created first, and then if certain
    criteria are met then an object of the second class will be created.
    Question:
    Should I use classical inheritance and let the first class inherit from the second class?
    Or should I use the containment delegation model and embed an object of the second
    class in the first class?
    ----Tables------
    For example, my first table ET_UserData looks something like this:
    ET_UserData
    (PK)UserName
    Password
    FirstName
    LastName
    My second table ET_DetailedUserData looks like this
    ET_DetailedUserData
    (FK)UserName
    WorkAddress
    WorkPhoneNumber
    CityWhereEmployed
    SocialSecurityNumber
    City
    State
    StreetAdress
    PrimaryTelephoneNumber
    AlternatePhoneNumber
    HasRegistered
    RegistrationDate
    RegistrationTime
    CreditCardNumber
    NameOfPrimaryContact
    DateOfBirth
    Weight
    EyeColor
    Height
    Member
    Here is are some pseudo classes for the two classes.
    Class UserData
    string UserName
    string FirstName
    string LastName
    Class DetailedUserData /* For a classical approach, sub class off of class UserData */
    /* UserData ThisUser --> Containment delegation model */
    string (FK)UserName
    string WorkAddress
    string WorkPhoneNumber
    string CityWhereEmployed
    string SocialSecurityNumber
    string City
    string State
    string StreetAdress
    Int PrimaryTelephoneNumber
    Int AlternatePhoneNumber
    Bool HasRegistered
    Int RegistrationDate
    Int RegistrationTime
    Int CreditCardNumber
    String NameOfPrimaryContact
    Int DateOfBirth
    Int Weight
    Int EyeColor
    Int Height
    bool Member
    }

    Thank you for your help. If you can continue to help me I would appreciate it.
    I and another developer did the database design. Pretty solid design. Plus we have all of the requirements
    which are very good too.
    Originally I wanted just one table to contain all of the data associated with a user. Instead of ET_UserData and ET_Detailed user data I wanted just one table. But I decided to break this table up into the two tables for the following reason.
    1.) This is a web application where each user logs into a web form. At a minimum, in order to use the website the session associated with each user needs the UserName, Password, First and last name.
    This is the data in the first table.
    If they choose to do more specialized functions on this website, then they will need all of the information (Attributes) that are located in the second table. In general 40% of the time all users will need information located in the second table.
    My reasoning for breaking the table into two seperate tables is that I wanted to minimize the amount of data involved in a result set, created from the sql query. The math tells me that 60% of the time most of the data in the result set will not be used.
    2.) If I create one class to represent all of the data/attributes in both tables, then my reasoning is that their will be alot of overhead in the single class because 60% of the time, a majority of the attributes are not needed and used.
    I would deeply appreciate your help with this. You seem to have great insight and advice. Please help me as I increase the duke dollars Sir.

  • Help with Photo Gallery using XML file

    I am creating a photo gallery using Spry.  I used the Photo Gallery Demo (Photo Gallery Version 2) on the labs.adobe.com website.  I was successful in creating my site, and having the layout I want.  However I would like to display a caption with each photo that is in the large view.
    As this example uses XML, I updated my file to look like this:
    <photos id="images">
                <photo path="aff2010_01.jpg" width="263" height="350" thumbpath="aff2010_01.jpg" thumbwidth="56"
                   thumbheight="75" pcaption="CaptionHere01"></photo>
                <photo path="aff2010_02.jpg" width="350" height="263" thumbpath="aff2010_02.jpg" thumbwidth="75"
                   thumbheight="56" pcaption="CaptionHere02"></photo>
                <photo path="aff2010_03.jpg" width="350" height="263" thumbpath="aff2010_03.jpg" thumbwidth="75"
                   thumbheight="56" pcaption="CaptionHere03"></photo>
    </photos>
    The images when read into the main file (index.asp) show the images in the thumbnail area and display the correct image in the picture pain.  Since I added the pcaption field to the XML file, how do I get it to display?  The code in my index.html file looks like this:

    rest of the code here:
            <div id="previews">
                <div id="controls">
                    <ul id="transport">
                        <li><a href="#" class="previousBtn" title="Previous">Previous</a></li>
                        <li><a href="#" class="playBtn" title="Play/Pause" id="playLabel"><span class="playLabel">Play</span><span class="pauseLabel">Pause</span></a></li>
                        <li><a href="#" class="nextBtn" title="Next">Next</a></li>
                    </ul>
                </div>
                <div id="thumbnails" spry:region="dsPhotos" class="SpryHiddenRegion">
                    <div class="thumbnail" spry:repeat="dsPhotos"><a href="{path}"><img alt="" src="{thumbpath}"/></a><br /></div>
                    <p class="ClearAll"></p>
                </div>
            </div>
            <div id="picture">
                <div id="mainImageOutline"><img id="mainImage" alt="main image" src=""/><br /> Caption:  {pcaption}</div>
            </div>
            <p class="clear"></p>
        </div>
    Any help with getting the caption to display would be greatly appreciated.  The Caption {pcaption} does not work,

  • Help with Switch statements using Enums?

    Hello, i need help with writing switch statements involving enums. Researched a lot but still cant find desired answer so going to ask here. Ok i'll cut story short.
    Im writing a calculator program. The main problem is writing code for controlling the engine of calculator which sequences of sum actions.
    I have enum class on itself. Atm i think thats ok. I have another class - the engine which does the work.
    I planned to have a switch statement which takes in parameter of a string n. This string n is received from the user interface when users press a button say; "1 + 2 = " which each time n should be "1", "+", "2" and "=" respectively.
    My algorithm would be as follows checking if its a operator(+) a case carry out adding etc.. each case producing its own task. ( I know i can do it with many simple if..else but that is bad programming technique hence im not going down that route) So here the problem arises - i cant get the switch to successfully complete its task... How about look at my code to understand it better.
    I have posted below all the relevant code i got so far, not including the swing codes because they are not needed here...
    ValidOperators v;
    public Calculator_Engine(ValidOperators v){
              stack = new Stack(20);
              //The creation of the stack...
              this.v = v;          
    public void main_Engine(String n){
           ValidOperators v = ValidOperators.numbers;
                    *vo = vo.valueOf(n);*
         switch(v){
         case Add: add();  break;
         case Sub: sub(); break;
         case Mul: Mul(); break;
         case Div: Div(); break;
         case Eq:sum = stack.sPop(); System.out.println("Sum= " + sum);
         default: double number = Integer.parseInt(n);
                       numberPressed(number);
                       break;
                      //default meaning its number so pass it to a method to do a job
    public enum ValidOperators {
         Add("+"), Sub("-"), Mul("X"), Div("/"),
         Eq("="), Numbers("?"); }
         Notes*
    It gives out error: "No enum const class ValidOperators.+" when i press button +.
    It has nothing to do with listeners as it highlighted the error is coming from the line:switch(v){
    I think i know where the problem is.. the line "vo = vo.valueOf(n);"
    This line gets the string and store the enum as that value instead of Add, Sub etc... So how would i solve the problem?
    But.. I dont know how to fix it. ANy help would be good
    Need more info please ask!
    Thanks in advance.

    demo:
    import java.util.*;
    public class EnumExample {
        enum E {
            STAR("*"), HASH("#");
            private String symbol;
            private static Map<String, E> map = new HashMap<String, E>();
            static {
                put(STAR);
                put(HASH);
            public String getSymbol() {
                return symbol;
            private E(String symbol) {
                this.symbol = symbol;
            private static void put(E e) {
                map.put(e.getSymbol(), e);
            public static E parse(String symbol) {
                return map.get(symbol);
        public static void main(String[] args) {
            System.out.println(E.valueOf("STAR")); //succeeds
            System.out.println(E.parse("*")); //succeeds
            System.out.println(E.parse("STAR")); //fails: null
            System.out.println(E.valueOf("*")); //fails: IllegalArgumentException
    }

  • Newbie help with 12i and firefox java issue

    We are in the testing stages for a 12i upgrade. I’m currently testing browser and java version compatibility using an upgraded test system. My problem is the version of java on the desktop client. IE7 will launch the apps fine with any version of java. However, any version of Firefox (including just released v3) will not launch java unless java version 5 update 13 is loaded. I’ve reviewed several metalink docs including 389422.1 and 393931.1 and have used the workaround listed forcing FF to use the older version of java. However, that means that we will have to roll out this older version of java to all clients to use Firefox. During my research I found where Oracle provides a techstack update for 11i (290807.1) that will fix this issue and allow Firefox to work with newer versions of java. Has anyone else run into this issue and if so how did you address it? Is there a 12i update that will fix this issue? I’m a newbie that’s started supporting Oracle, etc. so forgive me for any ignorance I show on the subject. Thanks in advance.

    Tod,
    It sounds like your Oracle E-Business Suite Release 12 instance is configured to request end-users to use JRE 1.5.0_13.
    Firefox has a known limitation (or feature, depending on your point of view): it will invoke only the specified JRE version requested by the E-Business Suite, even if later versions of the JRE (e.g. 1.6.0_03) are installed on the same desktop.
    This behaviour is explained in more detail in Note 290807.1 in Appendix A. Since this behaviour is hardcoded into Firefox, your options are:
    1. Configure your Oracle E-Business Suite Release 12 environment to request a later version of JRE installed on your Firefox-equipped desktops
    2. Use IE -- it doesn't enforce static versioning.
    3. Contact the Mozilla team and request that they provide a new option to use either static versioning (the status quo) or the latest JRE version installed on the desktop.
    Regards,
    Steven

  • Need Help With Military DTD Using FrameMaker 8

    Fellow Forum Members,
    I hope someone out there with experience in using Department of Defense DTDs with FrameMaker can contribute to this thread.
    Attached is the MIL STD 400051-2 DTD that needs to play with FrameMaker. Does anyone out there know where I could find FrameMaker templates already setup that comply and play with the MIL STD 400051-2 DTD standard? If the Department of Defense is freely distributing the MIL STD 400051-2 DTD, shouldn't somebody in the Department of Defense also be providing MIL STD 400051-2 FrameMaker Templates for free that are already setup?  I would greatly appreciate if anyone out there could provide an online source where I could download MIL STD 400051-2 FrameMaker templates.
    Lastly, can anyone out there clarify what the purpose of the entities are inside the "Charant" and "Boilerplate" folders?  The Department of Defense does not provide a readme file that define what the "Charant" and "Boilerplate" folders are about.
    Any info will be greatly appreciated. Thanks.

    I'll answer the specifics that I know about your questions, but please look at the post from Srini for additional info:
    1) Do i need to do full export using SYS/SYSTEM user.
    exp80 system/manager file=c:full.dmp log=c:\full.txt full=y consistent=yA full export will move as much information (metadata/data) as possible. In order to do a full export/import, you need to do this from a
    privileged account. A privileged account is one with EXP_FULL_DATABASE for export and IMP_FULL_DATABASE for import.
    2) Will there be any data corruption while export.The data in the objects that you are exporting is being read, nothing is written to user data. I'm not sure what this is available in 8.0.6,
    but if you need a consistent export, look to see if consistent=y is available in 8.0.6. All this means is that the dump file created will have
    consistent data in it.
    3) Is export/import the only method of migration/upgradation.If you are changing hardware, the only supported way from 8.0 to 10.2.0.4, that I know of, is using exp/imp.
    Hope this helps.
    Dean

  • Need help with security design!

    Hi,
    I haven't worked with security design very much. Currently I'm about to develop an application to my father which should implement some sort of security.
    One of the reasons for this application besides making my father happy is educating myself.
    The application is an online image album.
    The security could be divided in role-based security and instance level security.
    Role-based (NO PROBLEM):
    A user cannot delete another user, an administrator can delete users.
    Instance-level (DON'T KNOW HOW):
    A user can load other users image albums if he/her is allowed/granted to view the album and its images. Note that the user could be granted to view the album, but not all of its images.
    My problem is how I should design the "instance-level" security? Should I keep a ACL (Access Control List) with each instance of album and image?
    This seems to be a common functionality to add view/load/read/write permissions to an instance in runtime to let a certain user to operate on an asset?
    Have searched the Internet but haven't found any nice framework to help me.
    Could anyone with some experience please help me out?!
    Kind regards, Andreas

    Hi,
    I ran into the same problem. Could you resolve it?
    please give me your feedback.

  • How to replace namespace tag with new value using -JAVA MAPPING

    Hi Guys,
    I need to replace namespace Tag in Target xml with a new value.
    For Eg: My namespace Tag is - <ns0:TestHeader xmlns:ns0="http://0020.TestHeader.SS.com">
    I want My target xml to have value- <ns0:TestHeader>
    How can i achieve it using JAVA mapping?
    Can you provide me the code to do so.

    Sarjana,
    Not well-formed XML is only possible by Java Mapping. Please use below replace logic in Java map.
    inputContent.replaceAll("<ns0:TestHeader xmlns:ns0=\"http://0020.TestHeader.SS.com\">", "<ns0:TestHeader>");
    Link1, Link2.

  • Interaction with Microsoft Word using Java Programming

    writing Text ON TO MICROSOFT WORD USING java Programming Urgently required

    Go throuh jakarta POI(hssf) to do..No! HSSF which stands for Horrible SpreadSheet Format can be used for Excel (spreadsheets as the name suggests). For Word, you would need to lok at HPSF.

  • Design Choices in a Web-only Application Using Java Persistence - Question!

    Hi,
    Is it possible to use both container and application managed entity manager factories in the same web-only application?
    It is not working for me....
    I have an application that is using container managed (injected) emf and also an application managed emf. The behavior I see is that updates from the application managed emf are not being persisted to the database but it can query properly. The container managed emf works normally.
    However, there is no error for the application managed emf. Maybe this is because I am using hypersonic in my test environment?

    Duh, forgot to joinTransaction in the app managed emf
    Edited by: edge1 on Aug 20, 2008 10:42 PM

Maybe you are looking for

  • Issue in clearing of previous data of screen cl_gui_docking_container= free

    Hi All, My program displays an idoc list(screen 100). Then if user selects any row in the method gets the index no and details of that idoc are displayed in another screen(screen 200) . Then control returns to this screen again. Now if user selects a

  • Reference to a local variable object returned by a method is alive?

    I have an instance method getEmployee(). This method forms a local variable, Employee and returns it. public Employee getEmployee() Employee e = new Employee(); e.setSNo(sNo+=); e.setMailBox(); return e; There's another instance method in the same cl

  • MSS Java webdynpro - Employee performance management

    Hi all, I am looking for the RFC function module used to access the list of templates in the ECC backend ABAP. The iview used is in MSS Java web dynpro. Regards, Uday

  • 9-slice scaling problem on symbols

    Hi there. If I have a 9-slice scaling guide setup on a symbol, then drag it onto the canvas. I have an issue. When the image is dragged onto the canvas, the bounding box is too large, like it doesn't accurately represent the actual image data of the

  • Can't access any applications

    I was installing a new program (the Centra client for participating in online meetings)using Safari, and the Centra installer froze. I used Force Quit to get out of Safari. Once I did that, however, none of my applications would work and if I try to