Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!

Thomas Bigbee

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

Recent posts by Thomas Bigbee

Sounds like a homework question to me.
16 years ago
J2SE v5 will give you as much as you need to do anything with J2SE and EJB3, If you need to use EJB2 you will need to get J2EE, however, if you can help it, don't have anything to do with J2EE. My suggestion is to google EJB3 and read up on what is returned.
16 years ago
Your are going to have to user XDoclet if you need to be able to use Jave 1.4 or XDoclet or Annotations if you are using Java 5.0
The SCJD Exam is pretty small and simple, even then it takes most people months to complete (and pass).

You can have all the Certifications in the world with no experience and yet, loose out against some guy with no Certifications but loads of experience, this will happen 99.999% of the time.

It takes years of "real-world" experience to make a good programmer, I know that there are those who would disagree with me, however, they are wrong and I am right.

My suggestions are these:

Don't kill yourself trying to cram for a project that you can't finish.

Point yourself at a those positions where experience is not required, your SCJP will help you get your foot in the door, but just only.

Work on your resume and interview skills.

Take all interviews, even those that you are not interested in, that way you will be polished and poised when you do get that interview that interests you.

My own story is this. I had loads of knowledge but no experience, I interned one day a week (free of charge) for a year at a company making Nursing Software, before I felt that I had enough experience to pass myself off as a programmer.
16 years ago
I don't know if this will be of any help, if it is not, I apologize.

I use Eclipse 3.1 (which is free), putting my mouse over a fragment of code will usually give me back some pretty verbose information. Example:

Hovering the mouse over getLogger

Logger.log = Logger.getLogger(TestClient);

will give me "Logger org.apache.log4j.Logger.getLogger(String arg0)"

This tells me the Object, Method, Package and Arguments.

I know this is not run-time, and you don't get the jar or the jar's directory, however, since you have to add each jar to the Project and you can expand the jar and the package in the Package Explorer View, you know where everything is comming from, moreover, ambigous package class referneces are not allowed (wont compile until fixed).

With that said, one of the biggest reasons I moved from Textpad to Eclipse was the ability to debug conflicting class names, not that it happened very often, however, when it did, it took forever to find the offending jar.
16 years ago

You can find the documentation here:

I believe that the requirements state that you can assume that at most there will be only one person in the database at a time, I also believe the requirments also stated that is a record was locked, you were to wait until it was unlocked, and consume no CPU Cycles until then, however, with that said, you bring up a good point.

Typically you will be dealing with detached views of data. Think of it like this. On Ebay, you enter your bid 10 seconds before the bidding is over, you get a message back telling you that you are currently the highest bidder, you refresh the browser, only to find that you have lost.

The only way around this would be to hold a lock on the record, which is a bad idea for a number of reasons.

In the project you will be dealing with a detached view of a record, I don't think that there would be a very likely chance that somehow a record would be locked at the same time you are trying to save (update to the db) it, on the other hand, I think it is very likely that you may try to update a record that has already been updated.

Typically applications or frameworks (like Hibernate, etc...) handle this with versioning, (reading a version/update counter, etc...). You are not allowed to modify the db, so, the only way to handle versioning is to, lock the record for update and check the current record values against the original detached view of the data, if the match, great, if they don't, not so great.

I suggested this before (and am doing it in my own project) and it was derided, by those who obviously know more, however, using versioning would take care of your concerns, and also provide a more robust and correct application.
The book "Hibernate A J2EE Developer's Guide" has an extensive section on using xDoclet tags, I would not recommend the book for anything else though. When I went to the Advanced Hibernate course in Atlanta last week, the instructor told us that xDoclet was pretty much dead, as no new versions will be comming out because of EJB3 and Hibernate Annotations, he went on to inform us if you really wanted to use xDoclet, to go ahead and then he said some other things about xDoclet that I can't repeat.
I don't know what your exact code looks like, however, please let me take a shot at what may be the cause of your problems.

When you are in-between a transaction and you are adding and updating, etc.. noting is reflected until you do a or a session.saveOrUpdate(aClass) and then issue a flush(), changes are not being persisted so you are dealing with phantom objects (records) that do not exist, at least that's my story, and I'm sticking with it (for now).

On your save you should get a primary key back (as long as you are not using session.persist()

youPersistedId = (Integer);

Please accertain that this may be your issue. If I have nudged you in the wrong direction, you have my apolgies.

I would be more that happy to help, however, please note that I am a Hibernate Newbie myself. The below code works against a MySQL DataBase, the field on_date in the database is really a TimeStamp field, I know I should have named it on_timestamp, however, it works and I'm just too damn lazy to rewrite the code and database, also please be kind when reviewing the code, this may not be production grade, but at least it works.

You are adding employees to a project, try adding projects to employees. I may be misspeaking, however, let me try to explain. When you use inverse="true" in the project.hbm.xml you are telling Hibernate that changes to Projects (involving employees) are not to be recorded, and that the Employee table is the main table. You should always use an 'inverse="true"' on the many side of the realtionship.

In order to test this out I created your app from scratch, I then had it working, I plugged in your example code, guess what? not only did the emp_proj table not get populated but the employee table was empty as well. Save the employees as you go along, then before you add your projects flush() your changes to the DataBase.

Like I mentioned before, you may want to get rid of the mapping files and go stricly with Annotations, there much easier to use and alot easier to program and debug.

[ October 04, 2005: Message edited by: Thomas Bigbee ]
Greetings all

In most of the books I've read (on Hibernate) they specify that Named Queries should be placed at the bottom of the mapping file

From Hibernate Quickly...

Named queries, not to be confused with named parameters, are queries
that are embedded in the XML mapping definition. Typically, you put
all of the queries for a given object into the same file. Centralizing your
queries in this fashion makes maintenance quite a bit easier. Named
queries are placed at the bottom of the mapping definition files:

My question is this. When attending Advanced Hibernate Training in Atlanta last week, the instructor stated, that, Annotations should be used as opposed to Mapping files, with that said, Annotations allow you to place the Named Queries and the Package or Class Level, my questions is this: what is the difference between the two, and why would you pick one over the other?

Any feedback appreciated.

The below works using annotations, however that may not be the problem, Hibernate uses lazy loading by default, if you check the value of your Set it would be null

tx = session.beginTransaction();
List authorList = session.createQuery("from Author").list();

Iterator aIter = authorList.iterator();

while ( aIter.hasNext()) {
System.out.println("in while");
a = (Author);
Set <Book>aSet = a.getBooks();
Iterator bIter = aSet.iterator();
while ( bIter.hasNext()){
Book b = (Book);
System.out.println("the book for the autor is:" + b.getTitle());
System.out.println("Id " + a.getId() + " Name " + a.getName());

(in the Books.class)
protected Set <Book> books = new HashSet<Book>();

Notice how I have to call getBooks, even though in the author class, books is defined, it is null until you go out and get it by calling the getter method in the POJO, you can however specify that one table will be automatically joined (and only one table) when you execute your qurey, the rest would be lazily loaded.

By the way, I just got back from Advanced Hibernate Training in Atlanta specified that Annotations are the way to go, as opposed to Mapping Files, the best book I've found so far is Pro Hibernate 3 (even though there are a number of errors, they were using an early alpha version for the book)

I hava a Book class and table and an Author class ant table and a
intermediate table called Book_Author which consists of Book_Id and

Book Class (pk = id)

@ManyToMany (fetch=FetchType.LAZY,
cascade={CascadeType.PERSIST, CascadeType.MERGE}
public Set<Author>getAuthors() {
return authors;

Author Class (pk = id)

@ManyToMany(cascade = {CascadeType.ALL}, mappedBy = "authors")
public Set<Book>getBooks() {
return books;

Hope this helps, Tom
Thanks Berry, that did the trick
17 years ago
I've run across this warning, and I'm trying to figure out a way to correct it, I've tried to fix it using generics, however, I have not been able to make the warning go away.

Any feedback would be appreciated

Type safety: The method set(Object) belongs to the raw type ThreadLocal. References to generic type ThreadLocal<T> should be parameterized

public static final ThreadLocal session = new ThreadLocal();

public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null) {
s = sessionFactory.openSession();
return s;
17 years ago