Newbie generic question

I have a base class for all of my hibernate database classes called DBO. This base class provides some functionality that is common across all classes for example equals, and an abstract table model. It also has some abstract functions that the child class must implement like canDelete.
There is another feature I'd like to add to the base class, it is a static way to retrieve data from tables that dont change a lot ( for example for addresses I have a "type" table that stores "work", "home", "mailing", etc ). There's no need to constantly re-retrieve that data. I have about 30 or so tables like that. So originally I had this in in DBO_tAddressType:
     protected static Vector<DBO_tAddressType>All = null;
     @SuppressWarnings("unchecked")
     public static Vector<DBO_tAddressType> GetAll() {
          if (All == null) {
               Session newSession = HibernateUtil.getSessionFactory().openSession();
               List<DBO_tPlacingAs> messages = (List<DBO_tAddressType>)newSession.createQuery("from DBO_tAddressType").list();
               newSession.close();
               All = new Vector<DBO_tAddressType>(messages);
          return All;
     This way the first time it would load the table, and then simply return the cached data (I am going to include a refresh option as well).
This function however fits well into a base class using generics, I think. However I'm not sure exactly how to do this one.
What I can't get my head around is that static in the base class would tie it to a DBO object. However I really need one static All for each of the child classes derived from DBO.
Not sure if my question is clear or not. In fact I'm not entirely sure what question to ask. Is what I want to do possible? If so how?
Peter

Why are you trying to write the logic to cache the static table data ? Why not simply use the Hibernate L2 cache?
BTW, it does not seems to be generics related question. You could probably post in [database forum|http://forums.sun.com/forum.jspa?forumID=48] .

Similar Messages

  • Some generic questions on BPM of NW CE

    Hi Gurus
      i have over 6 years of ABAP business workflow experience and over 3 years of XI experience. Now i'm getting tough with this new stuff, BPM of NW CE. Here i have some generic questions of it:
    1. How can i trigger a BPM task while a document, like a sales order , has been created in the system? is there any processes to catch the event of R3 in NWDI?
    2. Can BPM consume RFC/BAPIs in R3?
    3. Is it possible to make message mapping in BPM? i found there is a 'mapping' choice in the context setting of NWDI whereas it is quite simple compared with PI.
    4. Can the BPM be integrated with webdynpro ABAP? or send the relevant tasks into R3 directly? Actually what i mean is , can i bypass java programing while dealing with BPM of CE, if possible.
    thanks

    Hi Stephen,
    In the first released version of SAP NetWeaver BPM it is not possible to catch events of R/3 directly. Anyway. In case you have the possibility to trigger a web service in that situation you could start off a specific (BPM) process instance that handles the situation.
    The same is basically true for the question regarding RFC: In the initial version you'd need to wrap the RFC into a web service in order to consume it.
    The mapping possibilities in SAP NetWeaver BPM are meant to perform data flow between different activities in a BPMN based process model. This way you could transform a message that came into the process in that way that if fits your needs in regards to the BPM process (data) context.
    Bypassing Java when using SAP NetWeaver BPM would be difficult as the supported UI technology is Web Dynpro for Java. In addition the possibility to add more flexibility to your mappings by defining custom functions is based on EJB, thus again Java.
    Best regards,
    Martin

  • General place for newbie datamodeler questions?

    With the production release of SQL Developer Data Modeler I'd assume that this forum will draw a bunch of new users. Is there a better place to ask some pretty simple, newbie like questions that won't bother the more seasoned members?
    For instance, I am working in a Rails environment, which has some stringent naming conventions, one of which is that all of the primary key columns are numeric and called "id", with the foreign key linked columns called <table_name>_id.  When engineering a logical model to a relational model, the added foreign key columns are all "id#".  Is there a way I can define a naming rule to keep me from having to redo the relation column names?
    Also, we have a standard set of columns (mostly Rails related) which appear in every table. Can I define a generation rule which automatically includes these tables?
    Thanks

    Thank you. I will try changing that setting.
    IS there a setting which tells the relational model to automatically create pk and fk indexes? I haven't seen one, and manually setting them up is a tedious task. --sw                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Some generic  questions about JMF

    Hi, as new to JMF, I would like to ask some generic questions about JMF from this community
    Though including RTP stack, JMF is only compatible to old RTP draft, RFC1889. I know that Sun stopped developing/supporting JMF. What is the alternative solution for JAVA RTP implementation suitable for a serious SERVER project, not just a school-term project? Has anyone thought about that or may have already moved forward? Is that any commercial or more updated Java based RTP stack currently? I searched with google. Besides jrtp, a school project, and I could not find a nice one. Majority of RTPstack implementation is C/C++.
    My second question is if there is the performance analysis and comparison of JMF. I know that some client applications such as SIP-Communicator adopt JMF for media delivery. But it is for one user in one machine. I wonder if any server application has adopt JMF as media relaying layer.
    I appreciate any input from this community.

    erwin2009 wrote:
    Hi, as new to JMF, I would like to ask some generic questions about JMF from this communitySure/
    Though including RTP stack, JMF is only compatible to old RTP draft, RFC1889. I know that Sun stopped developing/supporting JMF. What is the alternative solution for JAVA RTP implementation suitable for a serious SERVER project, not just a school-term project? Has anyone thought about that or may have already moved forward? Is that any commercial or more updated Java based RTP stack currently? I searched with google. Besides jrtp, a school project, and I could not find a nice one. Majority of RTPstack implementation is C/C++. There is one active project out there, Freedom for Media in Java, that has RTP capabilities. It's obviously not from Sun, but it's the only other RTP-capable project I am aware of, other than FOBS4Java, I believe is the name of it.
    What they are suitable for is beyond my scope of knowledge, I only know of the 2 projects.
    My second question is if there is the performance analysis and comparison of JMF. I know that some client applications such as SIP-Communicator adopt JMF for media delivery. But it is for one user in one machine. I wonder if any server application has adopt JMF as media relaying layer. None that I have seen, except for various projects I've helped people with on this forum. But, if someone is asking for help on a forum with his/her server application, it probably doesn't meet the guidelines you just laid out ;-)
    I appreciate any input from this community.Sorry I don't have more to add to your inquires...

  • Somewhat complicated nested generics question

    I have a slightly complicated generics question. I have some parameterized code that looks something like:
    public <T extends MyBaseObject> Map<String,T> loadObjectCache (Class<T> clazz) {
        // load objects of type T from somewhere (file, database, etc.)
        List<T> objs = loadObjects(clazz);
        // create map to store objects keyed by name
        Map<String,T> map = new HashMap<String,T>();
        for (T obj : objs) {
            map.put(obj.name(), obj);
        return map;
    public static void main (String[] args) {
        // load objects of type Foo (a subclass of MyBaseClass)
        Map<String,Foo> map = loadObjectCache(Foo.class);
        // retrieve a Foo by name
        Foo foo = map.get("bling");
    }This all works great, and the parameterization helps me avoid some annoying casts. Now let's suppose I want build these maps for multiple classes, and I want to create a second-order cache of objects: a Map which is keyed by Class and contains elements each of which is a Map as above (keyed by name, containing objects of the given class). So, I'd like to declare something like:
    Map<Class,Map<String,Object>> metaMap = new HashMap<Class,Map<String,Object>>();However, this doesn't quite work. The compiler complains about the following code added just before the return in loadObjectCache() because a Map<String,Foo> is not a subclass of a Map<String,Object>:
        metaMap.put(clazz, map);So, What I'd like is some way to make the above declaration of metaMap such that the objects in a given inner Map are checked to be of the same type as the Class used to store that Map in the meta-map, something like:
    Map<Class<T>,Map<String,T>> metaMap = new HashMap<Class<T>,Map<String,T>>();But this isn't quite right either. I don't want a Map that uses a particular Class as its key. Rather, I want a Map that uses multiple Class objects as keys, and the element stored for each is itself a Map containing objects of that type. I've tried a variety of uses of Object, wildcards, etc., and I'm stumped. I currently have the meta-map defined as:
    Map<Class,Map<String,?>> metaMap = new HashMap<Class,Map<String,?>>();Then in my new getObjectByName() method, I have to use an ugly cast which gives me a type safety warning:
    public <T> T getObjectByName (Class<T> clazz, String name) {
        Map<String,T> map = (Map<String,T>)metaMap.get(clazz);
        return map.get(name);
    }If anyone know how I should declare the meta-map or whether it's even possible to accomplish all this without casts or warnings, I would much appreciate it!
    Dustin

    Map<Class<?>,Map<String,?>> metaMap = new
    new HashMap<Class<?>,Map<String,?>>();
    public <T> T getObjectByName (Class<T> clazz,
    azz, String name) {
         Map<String,?> map = metaMap.get(clazz);
         return clazz.cast(map.get(name));
    }Cute. Of course, that's really only hiding the warning, isn't it?
    Also it doesn't generalize because there's no way to crete a type token for a parameterized class. So you can't use a paramterized class as a key, nor can you nest 3 Maps.
        public static <U> void main(String[] args) {
            MetaMap mm = new MetaMap();
            Appendable a = mm.getObjectByName(Appendable.class, "MyAppendable");
            Comparable<U> u = mm.getObjectByName(Comparable.class, "MyComparable"); //unchecked converstion :(
        }Hey, not to sound ungrateful though. The solution posed is very useful for a certain class of problem.

  • Newbie script question... consecutive numbers with update.

    complete newbie type question... this is also my first post.  ( I am using CS3)
    does anyone have a script which can make it so I can add numbers into the text consecutively.
    for example, if this is my text "the big fat dog sat on the very wide mat, but was then displaced by a unfriendly cat."
    and I wanted to place a number 1, number 2, 3, etc at points in the text so it read, "the big fat dog1 sat on the very wide mat2, but was then displaced by a unfriendly cat3." but later wanted to add another number and have later numbers update themselves, so the text then said, "the big fat dog1 sat on the very wide mat2, but was then displaced3 by a unfriendly cat.4".
    by inserting the three, the previous three became four.
    Has anyone got something which might be useful in this regard.
    Many thanks
    Steve

    i wanted to avoid footnotes as they leave a bar at the bottom of each page.
    i wanted a script to do something similar to footnotes but not much further.
    does anyone have just a simple script that can do what I asked?
    Steve

  • One more generics question

    One more dumbshit generics question...
    Is there a way to do this without the warnings or the @SuppressWarnings({"unchecked"})
       * Returns the index of the last occurrence of the specified element in this
       * list, or -1 if this list does not contain the element.
      //@SuppressWarnings({"unchecked"})
      public int lastIndexOf(Object object) {
        int i = 0;
        int last = -1;
        for(Node<E> node=this.head.next; node!=null; node=node.next) {
          if (node.item.equals((E) object)) {
            last = i;
          i++;
        return(last);
    produces the warning
    C:\Java\home\src\linkedlist\LinkedList.java:313: warning: [unchecked] unchecked cast
    found   : java.lang.Object
    required: E
          if (node.item.equals((E) object)) {
                                   ^... remembering that List specifies +public int lastIndexOf(Object object);+ as taking a raw Object, not E element, as I would have expected.
    Thanx all. Keith.
    PS: Crossposted from the tail of http://forum.java.sun.com/thread.jspa?messageID=10225418&#10225418
    which nobody has answered, I presume because the thread is marked as "answered".

    I'm not sure you understood or if I made myself clear. Or perhaps I'm missing a vital detail in your implementation.
    I'm talking about the cast to E in this line:if (node.item.equals((E) object)) {Object.equals() takes a parameter of type Object. So the cast to E is superfluous. That cast is what's causing the warning. You remove the cast => no more warning => you can remove the SuppressWarnings annotation.
    Unless your E's have an overloaded equals() that takes an argument of type E. In that case you'll have to live with it.

  • Newbie XSan question - authenticating a computer from XSan Admin

    Hello - I have a very newbie XSan question!
    I have 2 computers that connect to an XSan. 1 I am having no problems with. The other I am unable to connect with.
    When I look in XSan Admin the 2nd computer (the one that is not working) is not authenticated.
    So I click on it and choose Authenticate. I enter what I know is an Admin username and password for the computer I am attempting to connect. The dot next to the computers IP turns green with 3 dots in it and then it turns gray again. It just does not connect.
    What is the problem?
    Is it licensing?
    Thanks
    Taj

    You need a different license ID for each machine, plus the admin machine. Do you have that?

  • Adobe Edge - generic questions

    Hi,  I've a couple of fairly generic questions regarding Adobe Edge:  - Is it part of the Adobe Creative Cloud? - I'm looking to produce animated online web ads (leader board / MPU) As far as I'm aware I can produce HTML 5 in this, is this correct?  Can I also produce .swf files too?  My overall aim to get trained on a package which can produce online interactive animated ads (which will play on both PC and Apple devices old and new).  Flash only seems to produce .swf (don't work on some Apple products) Is Edge the answer?  Thanks in advance,  Andy

    Hi, Andy-
    Edge Animate is available for download from the Creative Cloud, so you should already be able to see it in your offerings.  Animate works natively in HTML, so it can't output SWF.  I believe Flash can export to Canvas using CreateJS (http://www.adobe.com/products/flash/flash-to-html5.html), but Canvas support is uneven across all browsers.  We are working with other advertising agencies, so I can tell you that there is good interest in Edge Animate as a solution for HTML-based animated advertisements.
    Hope that helps you,
    -Elaine

  • This Newbie Has Questions

    Hi there. I am a newbie to Apple. I purchased the iBook last month and of course, when the MacBook (which had the features I wanted) came out, I rushed out and got one and I'm very pleased with my purchase - but I have a few "newbie" questions:
    1) Printing on a PC based Linksys seems to be a nightmare. I can't get anything printed on the shared HP 2600N and HP1012 printers. I literally have to disconnect them from the PC and plug the USB directly to my MacBook to print. It seems like there should be a better, easier and MacFriendly way of doing this - anyone have an easy solution?
    2) I'm going to purchase Windows XP so I can run my windows programs on this computer. Does anyone have any pre-installation advice?
    3) I have a blackberry device that worked fine with my iBook, but does not work with my MacBook - any suggestions or is there a software compatibility patch?
    4) I transferred everything from my old Mac to my new Mac with no problem. How can I migrate my contacts from Entourage to the Address Book?
    5) I notice that sometimes the MacBook "stalls" or doesn't work fast in some functions...is it just me - I expect the machine to jump quickly...but sometimes I get that annoying pinwheel when opening programs.
    Thanks for your help!

    1) Printing on a PC based Linksys seems to be a
    nightmare. I can't get anything printed on the
    shared HP 2600N and HP1012 printers. I literally
    have to disconnect them from the PC and plug the USB
    directly to my MacBook to print. It seems like
    there should be a better, easier and MacFriendly way
    of doing this - anyone have an easy solution?
    The problem is probably a driver issue.
    Printing to a printer on a XP PC from a Mac running 10.4.x
    http://www.ifelix.co.uk/tech/3015.html
    You may need to use a third-party driver such as the HPIJS drivers or the Gimp-Print drivers, but this is not the case with all printers.
    2) I'm going to purchase Windows XP so I can run my
    windows programs on this computer. Does anyone have
    any pre-installation advice?
    Ensure you get a full version (not an upgrade version) and it comes with XP SP2 already.
    Do not install Boot Camp on a critical machine and make regular backups of your data, this is beta software and there are bugs and issues.
    5) I notice that sometimes the MacBook "stalls" or
    doesn't work fast in some functions...is it just me -
    I expect the machine to jump quickly...but sometimes
    I get that annoying pinwheel when opening programs.
    Are these Universal or PPC only applications?
    iFelix

  • Newbie wireless question (slightly off-topic)

    I didn't want to post this here as it's not entirely an Airport-specific question. I posted this to the iBook forums, but nobody there has answered so my apologies if this is not welcome here. (Any moderators can remove it if that's the case.)
    I've been using computers extensively for over a decade, but I'm a total newbie to wifi. I just set up a wireless network in my house and would appreciate some advice/feedback.
    My main concerns are whether or not my network is reasonably secure. I know there is no such thing as perfect security, but I don't know if what I've done is good enough or not.
    I don't have an Airport base station, but I do have a D-Link Airplus G and an Airport card in my iBook. I have WEP set up on the router and I have enabled MAC filtering, listing only my desktop and my iBook, excluding all others from the network.
    I'm fairly certain that nobody in my neighborhood is going to get into my machines this way or be able to sniff my network data stream, but am I right in assuming that nobody can "piggyback" on my Internet connection too? Presumably, if everyone but my own machines are MAC-filtered and kept out, then the Internet connection is also protected. Is that how it works?

    WEP and MAC filtering are better than nothing, but you can do better. These are my suggestions:
    1. Use WPA with a pre-shared key (PSK) and TKIP encryption on your Netgear router, along with an alphanumeric passphrase of at least eight characters not found in any dictionary. The equivalent setting on your Mac is "WPA Personal". Unlike WEP security (which an expert can crack in under half an hour), WPA security is currently unhackable by any practical means as long as you use a non-dictionary passphrase. One last point - WPA security requires all your wireless Macs to be running MacOS 10.3 or newer.
    2. MAC filtering is (these days) essentially useless as a wireless security method. Using "packet sniffing" of traffic on your wireless network to find out what MAC addresses are used by computers on your network, and a PC that allows its MAC address to be cloned so that it is identical to the MAC address of one your own wireless computers (which is possible with most PC wireless network adapters) even an amateur hacker can defeat MAC address filtering in minutes.
    By the way - I don't think your posted message here is off topic. In my opinion, the Airport discussion forums are the best place to post any questions related to usage of wireless networks. Questions of this nature are virtually never specific to any Mac model.

  • Generic questions about CMYK profiles and proofing

    I just read a big book about color management and am trying to make it happen but it seems that in real life I can't get good results.
    I have my scanner profiled and it produces aRGB docs.
    All good and fine. The images look good on the monitor (which also is profiled.)
    Now these images I place inside InDesign as aRGB.
    And at some point comes the time for soft proofing.
    So I start experimenting with different CMYK profiles.
    First question: Should I already do a CMYK conversion for my images in Photoshop or is it ok to do it in InDesign when exporting to PDF?
    Coated Fogra27/39, ISO Coated v2 and Euroscale Coated v2 seem to change the colors only slightly.
    But when I turn on "Simulate Paper Color" all hell breaks loose. The paper color seems to be always a cold horrible grey and the image is darkened and dulled. It looks like in need of serious color correction.
    And further how do these generic profiles know about my paper color anyway?
    So maybe this feature should only be used if the profile is custom made for a specific printer and paper.
    Second question: has anyone succesfully used the simulation of paper color with a custom made profile?
    But it seems that custom profiles are something I can only use at home because the printing service providers seem to be quite unaware of profiling their machines for a specific paper (or profiling it at all).
    They tell me to send a "pure" CMYK file without any profiles. But that is impossible because to transform an RGB in CMYK one MUST use a profile.
    Third question: Which kind of profile should I use when I am instructed to provide a profile-less CMYK document?
    And finally what is the purpose of proofing in the first place if I don't know exactly the profile created for the combination of the output machine and output paper? This issue becomes clearer when using (slightly) colored paper.
    - Rami Ojares

    >First question: Should I already do a CMYK conversion for my images in Photoshop or is it ok to do it in InDesign when exporting to PDF?
    You can save the conversion until you make the PDF if you like, especially if you don't know the correct profile in advance, but you lose the ability to fine-tune and individual image.
    >But when I turn on "Simulate Paper Color" all hell breaks loose. The paper color seems to be always a cold horrible grey and the image is darkened and dulled. It looks like in need of serious color correction.
    I think this is mostly a case of your eye accommodating to the brightness of the screen. I'm not sure how to avoid this, and I generally don't use the simulate paper color. Comparing my screen to the real printed output without the simulation seems pretty close. Even a generic profile makes an assumption about the color of the paper stock, but a custom profile would be more accurate.
    >Third question: Which kind of profile should I use when I am instructed to provide a profile-less CMYK document?
    As you already said, you can't do the conversion without knowing the profile. What they are asking is that you don't embed that profile when you do the conversion to PDF. This means they can use a file prepared for the wrong profile and not risk further conversion at the RIP which would create rich blacks from you 100% K elements (type), but the colors wouldn't be 100% correct unless the profile you chose for conversion originally matched the press.
    Generic profiles are a quasi-standard that most presses can match, but may not be able to produce quite as wide a color gamut as a custom profile, but many presses don't have a custom profile available. You should ask for a "contract proof" to check the color before the press runs, and if possible go to the printer for the make-ready and check the color on the press before the whole run is printed. There is a LOT of color control available to a skilled press operator, and expect some variation through the run.
    Peter

  • Newbie saving question in Illustrator

    I know this is a newbie question. I designed a logo in Illustrator. Is there a way to save just the logo for exporting into other applications (ie Pagemaker or Photoshop) without having the white artboard?
    Thanks
    Brad

    I don't know Pagemaker but with Photoshop I simply select all, copy and then paste in Photoshop - transparency will be maintained. If you paste as a Smart Object you retain the ability to edit the Illustrator artwork in Illustrator and update the PS file.

  • The Java Tutorials : Lesson Generics Question and Answers

    Hello,
    I've just finished reading the Generics Lesson from the Java Tutorials,
    http://java.sun.com/docs/books/tutorial/java/generics/index.html
    and was hoping to see the answers in the Question and Answer section at the end of the tutorial, but the link doesn't seem to be working.
    Could someone please grade my answers?
    The question is (copied from the Java Tutorials):
    1. Consider the following classes:
        public class AnimalHouse<E> {
            private E animal;
            public void setAnimal(E x) {
                animal = x;
            public E getAnimal() {
                return animal;
        public class Animal{
        public class Cat extends Animal {
        public class Dog extends Animal {
        }For the following code snippets, identify whether the code:
    * fails to compile,
    * compiles with a warning,
    * generates an error at runtime, or
    * none of the above (compiles and runs without problem.)
    a. AnimalHouse<Animal> house = new AnimalHouse<Cat>();
    b. AnimalHouse<Dog> house = new AnimalHouse<Animal>();
    c. AnimalHouse<?> house = new AnimalHouse<Cat>();
    house.setAnimal(new Cat());
    d. AnimalHouse house = new AnimalHouse();
    house.setAnimal(new Dog());
    My answers are:
    a. fails to compile
    b. fails to compile
    c. compiles and runs without problem
    d. compiles with a warning
    I realize that I could re-read the tutorial, but aside from learning about Generics, I'm also trying to gauge how well I absorb new information, the first time I read it, so I would appreciate if someone could tell me if my answers are correct. Explanations for incorrect answers would also be appreciated.
    Thanks

    Hi,
    as far as I understand it, and am able to explain, creating
    new AnimalHouse<Cat>();has the knowledge (at compiletime) about the generic type Cat.
    But as soon as this is assigned to
    AnimalHouse<?> house = new AnimalHouse<Cat>();the variable house, this knowledge is lost for the variable house. So you have house which does not know the underlying generic type used. Then, there are either two options:
    - allow adding anything via the set...-method
    - do not allow adding/setting anything at all
    In the first case, you would create the problem of being able to potentially add instances of types that do not have any relation to the originally used type Cat - which will cause problems (imagine setting a Car instance instead of a Cat instance and lateron expecting to retrieve something that should be a Cat but is a Car...).
    So, the only safe option is the second one.
    Weird to explain, but maybe there are better explanations around...
    Bye.

  • Dumb newbie hardware question! :)

    Hi folks,
    I'm new to the world of the blackberry and am just about to take the plunge with an unlocked sim-free BB Bold to use in the UK on Vodafone. I have read about the software differences between BIS and BES and would be going for a BIS set-up. My dumb newbie question is does the hardware come in BES and BIS versions or not?
    Many thanks in advance and feel free to mock my foolishness
    Solved!
    Go to Solution.

    hello, about BIS and BES it's explained on the website but it's clear that if someone sums it up for you it will be easier...
    so BES is a type of contract between a company and Blackberry. The company IT buy computers, put Blackberry servers, and buy a fleet of Blackberry Devices for the people in the company to use them and get email through the Blackberry servers.
    BIS is a type of contract between a common person and a carrier. The consumer goes to the carrier, and buys a Blackberry device, and a BIS plan that will enable him/her to :
    phone/sms/mms
    receive emails that have been configured on the BIS site
    do data things if you subscribe to (like browse the web)
    You can buy a Blackberry from a carrier that has a deal with RIM (the company that sells Blackberries). Or you can buy a blackberry alone, and then go and contact a carrier that has a deal with RIM.
    phone/sms/mms
    receive emails that have been configured on the BIS site
    do data things if you subscribe to (like browse the web)
    The search box on top-right of this page is your true friend, and the public Knowledge Base too:

Maybe you are looking for