Joseph Maddison

Ranch Hand
+ Follow
since Nov 04, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Joseph Maddison

> I'd bet its more likely due to confusion with transactions.

That's possible. I did some more testing and it appears that the SQL update statement is not getting to the database for whatever reason. I've worked around that now.

> Hibernate has two caching layers. Which one are you talking about?

Both the 1st and 2nd level caches, if possible, though the session level one won't really have much in it, if it's specific to this JSP that just dumps the caches.

Thanks,
jdmaddison
It's been hinted at by a Hibernate guru/coworker who is more than willing to leave it as an exercise for someone else, that it is possible to somehow code a simple JSP that tells the Hibernate persistence layer to dump all cached rows and/or refresh them from the database. Any ideas on how this would be done?

This comes up because I am using JDBC SQL queries to set/reset data for automated (JUnit) testing. My EJB's are not always picking up the revised data and I suspect that it is due to caching.

At worst, I could switch to using the Hibernate backed entity classes to set up the data for the test, but I was hoping to be able to keep the code simple enough that it could be used to test behavior on multiple, similar tables. Perhaps using reflection with the entity classes could make this more reusable, but I'm not sure that I want to get that deep into it, just for testing. Anyway, I just thought I would ask.

Thanks,
jdmaddison
Minneapolis, MN
> I think that should be add one and then change the sign.

I think you're right. I was mostly trying to use the bit patterns to figure out the shortcut I needed, since it's hard to keep even these rules straight all the time.

Thanks,
Joseph
14 years ago
First of all, I can hardly believe this myself, but I've pinched myself and I'm not dreaming! I know the actual questions one gets are random, so there's certainly some luck involved with this. I haven't even scored close to 100% on any of the practice exams... but each time, I made sure I knew why I got the answer wrong. If I just couldn't get it, I would try compiling the code... or asking around here in the forums.

The $75 Sun practice exams were worth it to me, but they did not use the actual exam's user interface. The UI on the exam is slightly better-- it will not let you select too many answers. The practice exams did not show the elapsed time or the question numbers. Having those on the real exam helped me pace myself.

I started with the Sybex 4th edition Complete J2C (1.4), by Heller & Roberts (nominally also by a designer of the Sun tests) and went through it once, but gave up on it after too much errata and practice test questions that had answers that were dated, such as the distinction between keywords and literals which Sun explicitly denied. The book also came on the CD as a PDF, but I had to install bunch of stuff to get it to work, so it was a hassle.

I bought the the Osborne SCP&D for Java 2, what folks around here affectionately refer to as K&B, last October. It was much easier to read, the CD has the chapters in plain PDF without the added hassle. It was just plain good, plus it led me to this site from literally the first page past the copyright notice. It was printed in 2003, but it had most of the errata online taken into account (though not always accurately-- I sent an email to K a few months back with my take on it).

I studied off and on, reading through the K&B once, taking the practice exams after each section, and finding all the online practice exams I could find. A few days before the exam, I went through the first 8 of Dan Chisholm's exams (linked from here). They were good, but very, very tough in places. I retook the Sun practice exams (your $75 gets you 3 different sets of questions, (with answers explained) which you can take over and over again.) ... and I skimmed through the K&B once more, reading the bold sections, and taking the practice questions again. It was a great help.

A few small things not emphasized in K&B, that I picked up elsewhere:
  • Big Farms Need Red Tractors (Dan Chisholm) - the list of valid character escape codes \b \f \n \r and \t, along with \\, \", and \'.
  • ~ shortcut - change the sign and subtract one
  • To get the 2's complement negative value from the positive value, subtract one and invert
  • To get the 2's complement positive value from the negative value, invert and add one
  • I couldn't keep those straight, so I just remember the bit patterns for 1, 0, and -1 (FFFF). Need to get the negative of a number? What did I have to do to get -1 from 1? Just do the same...

  • Surprises. I wasn't allowed to take my water bottle in with me. The exam room was under video observation. Neither was a big deal. I also discovered I went through the exam in about an hour. I went over the questions I marked for review and answered those as best as I could.

    Then, I went back to the beginning of the exam and stepped through each question and thought very hard about tricks on each one. Several answers I changed after staring at them for a few minutes, and getting an "aha!" moment. I didn't think I'd be able to review all of them this thoroughly in the remaining time, but I kept at it, and finished with about 20 minutes to spare. Then I did what for me was the hardest thing-- I clicked submit, rather than try to review things even more. The rest, as they say, is history.

    Interestingly enough, I found an error in one of the Sun questions. I brought up a question a few weeks ago about how most checked exceptions have to actually be thrown in order for the compiler to let you use "throws X" on the declaration line for a method. This was because one of the Sun practice exams took advantage of the fact that this checking is not performed for "Exception" but is for subclasses. That is, throws X with an empty method won't compile. Well, the actual Sun exam had something similar, but it didn't affect the answer... but it was interesting to see.

    Thanks so much to K&B, JavaRanch, Dan Chisholm, Marcus Green, and all you folks in the forums for your answers and guidance.

    Sincerely,
    Joseph Maddison

    P.S. Thanks again for K&B, especially the coverage of assertions!
    14 years ago
    I'm adding a link to another posting that's related to this one. The compiler catches most checked Exceptions that are never actually thrown in the try block, except for Exception, which it will never complain about not being thrown... even in an empty try block!

    Topic "Exception class is special?"
    http://www.coderanch.com/t/375599/java/java/Exception-class-special

    jdmaddison
    14 years ago
    Please see my thread in the Intermediate Forum "How smart is the Javac compiler?"

    http://www.coderanch.com/t/375633/java/java/smart-Javac-compiler

    Hope this Helps,
    jdmaddison
    FileReaders are character oriented and depend on the default character set of your environment and may incorrectly represent binary data. My experience has been that if you work with Streams instead, you won't run into that situation.

    Hope this Helps,
    jdmaddison
    14 years ago
    From http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Void.html, The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the Java keyword void.

    Not exactly sure what one would use Void.TYPE for, but perhaps it's useful for someone.

    HTH,
    jdmaddison
    14 years ago
    Is there a way to inspect JMS Queue Messages, without resorting to modifying the sender or receiver applications? I'm specifically asking about a WebLogic 7.0 installation.

    Thanks,
    jdmaddison
    I've sometimes run into a situation where using a File object appears to somehow "lock" the file in question, but I'm not sure that's even the case here. You might try building the destination path + filename into a temporary String and use that instead of File.getName().

    Here's an example that has worked for me... it successively appends "-a" to the filename untill it succeeds or reaches the limit of 10.


    HTH,
    jdmaddison
    [ January 28, 2005: Message edited by: Joseph Maddison ]
    14 years ago
    Hi, it's a little tricky. Strings are not primitives-- they're objects. Primitives compare as you'd expect with ==, but with objects, == compares addresses in memory, so unless you're comparing an object with itself, it won't be equal.

    For objects comparision, there are two parts-- first, make sure that it is not null, and then call the equals() method on it. So, something like



    Hope This Helps,
    jdmaddison
    14 years ago
    Maybe you could write the command to a batch file/shell script and execute that file with Runtime.exec()?

    HTH,
    jdmaddison
    14 years ago
    Yes, I think you have the right idea. Here's what I use.



    Enjoy,
    jdmaddison
    14 years ago
    I could be missing something here, but have you already considered using the load and store methods of the Properties class? It looks like all you need to do is open the file and call Properties.load() with the InputStream.

    HTH,
    jdmaddison
    14 years ago
    Integer.MIN_VALUE is -(2^32). Integer.MAX_VALUE is (2^32)-1. That minus 1 is important. If you negate (or take the absolute value of) Integer.MIN_VALUE, it silently overflows and results in itself, because an Integer can not represent 2^32. If you cast these into a Long before negation, you will see the behavior you expect.

    Hope This Helps,
    jdmaddison