-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Errata Java Persistence with Hibernate : 5th print Nov 2007
PostPosted: Fri May 16, 2008 2:41 pm 
Newbie

Joined: Fri May 16, 2008 1:42 pm
Posts: 10
Listing 2.8 build.xml P61
remove redundant mkdir from clean and leave in compile..
You can also remove from targets like copymetafiles to..
see ejb3 example for ch2 in jpwh-gettingstarted-070401\helloworld-ejb3

Also you know you can access the 'built-in' ant property to assign what you always give proj.name.
This way you don't have to hard code same string twice..
So you end up with:
<property name="proj.name" value="${ant.project.name}"/>
So if you have
<project name="Hello World Reverse" ...
${ant.project.name} will contain "Hello World Reverse"..
Just a tip. I'm not sure how long this has been in Ant for...

P68
2.2.1 Using Hibernate Annotations.
I downloaded Hibernate-Annotations 3.3.1GA and readme in extracted lib now indicates hibernate-commons-annotations.jar is also a requirement these days. Book is "future proof" as is, but may be worth mentioning this in newer versions?

P89
2.3.1 Creating a database configuration..
You also need to copy across database folder, add ant task for startdb (taking out the delete of database folder!)
Unless there is a better way...
Otherwise by the time you get to P91 where it says "If you now run the ant target.. You're not going to achieve much!
Saying things like "lib folder and usual contents". Not so good.
I noticed Jtidy and Freemarker.. Didn't mention these before. So how usual is that?! Misleading without your download!
Aha now we find a reference to these two on 91. Should have been back on p89...
Would it be prudent to ask user to get these from \eclipse\plugins\org.hibernate.eclipse_3.2.1.GA\lib\tools folder, or equivalent version. As I take it these (incl hibernate-tools) work in conjunction with each other & you probably need compatible version?

readme for hello-world reverse is wrong in download of: jpwh-gettingstarted-070401\helloworld-reverse.
Quote:
1. cd ../helloworld-native
2. ant run.db
3. Open a new shell window
4. ant run
5. cd ../helloworld-reverse
6. ant reveng.hbmxml OR ant reveng.pojos OR ant reveng.entities

You have target to do schemaexport first before run. (I can forgive this as you would expect reader to have done this. Not the case if you cut your own version though)
Also I think when you've said in 2 run.db, I take it you meant startdb..

Needless to say. Can't get either your or my own version of reverse engineer to play ball.
Comes up with:
Code:
C:\Book Downloads\Java Persistence with Hibernate\jpwh-gettingstarted-070401\hel
loworld-reverse>ant reveng.hbmxml
Buildfile: build.xml

reveng.hbmxml:
[hibernatetool] Executing Hibernate Tool with a JDBC Configuration (for reverse
engineering)
[hibernatetool] 1. task: hbm2hbmxml (Generates a set of hbm.xml files)
[hibernatetool] log4j:WARN No appenders could be found for logger (org.hibernate
.cfg.Environment).
[hibernatetool] log4j:WARN Please initialize the log4j system properly.

BUILD FAILED
C:\Book Downloads\Java Persistence with Hibernate\jpwh-gettingstarted-070401\hel
loworld-reverse\build.xml:56: java.lang.NoClassDefFoundError: freemarker/templat
e/TemplateException

Total time: 0 seconds
C:\Book Downloads\Java Persistence with Hibernate\jpwh-gettingstarted-070401\hel
loworld-reverse>


In lib folder have tried two versions of files:
Yours:
freemarker.jar (Manifiest says Impl 2.3.4)
jtidy-r8-21122004.jar
Mine. Latest from Eclipse: / jars associated to 3.2.6GA of Hibernate
jtidy-r8-20060801.jar
freemarker.jar (Manifiest says Impl 2.3.8)

Both mess up.
Also tried adding
log4j-1.2.11.jar
But didn't help..
Any ideas?
See also: http://forum.hibernate.org/viewtopic.php?p=2385586#2385586

Resolved this puppy over in other thread.
In essence: Be sure to tell folks to copy freemarker/jtidy/bsh to one of Ant libs to avoid classloader issues with Ant.
Ie Ant home\lib or <user profile>\.ant\lib. I prefer latter, so I can see stuff I've added compared to ant baseline jars.

Back on P89 again section 2.3.1
Would be better if Ant task had better comments like so:
Code:
                <hbm2hbmxml/> <!-- Export Hibernate XML file: Creates src\hello\Message.hbm.xml. Same as Listing 2.2-->
                <hbm2cfgxml/> <!-- Export a hibernate.cfg.xml file:
                    Creates src\hibernate.cfg.xml. Similar to Listing 2.4.
                                   No pooling mapping resource. With:
                                   <mapping resource="hello/Message.hbm.xml" />-->


There is talk in section 2.3.3. P93/4 about customizing generated code output from hbm2hbmxml before being fed into hbm2java...
I've seen something in an example Matt Raible did using XDoclet with his resume example (using Appfuse in Pro JSP 2.0 4th ed chapter 15) whereby he used a merge directory to bring together code fragments. This way you don't lose your customizations when you regenerate. Is there a topic you can point me to that discusses similar issues in a 'hibernate context'? Only it seems plausible if you run hbm2hbmxml again you'd wipe out your customizations. I'd think this might quite likely an occurence in an environment where database changes might arise...
PS:I've also used technologies in the past that included things like pre-compile directives at top of source code. The directive invokes a custom program that modify source before compile doing searches along with replaces/inserts/deletes. This way your code could pull in customizations by re-inserting fragments into templates using a customization routine specified at top line of source. Regen program would extract directive and re-insert from existing code. (Synon code generator was technology I was thinking about). Maybe just add a comment like <!-- Custom --> after each node. Then use Sax parser to note nodes in terms of parent/child relationships where things existed. Store results in some sort of map and re-apply on regenerated code.. Just a thought. Could rename old file .bak so people could verify results...

P 95 better commenting again:
Code:
            <hbm2java jdk5="true" ejb3="true"/> <!-- Generates annotated class with javax.persistence imports -->
            <hbm2cfgxml ejb3="true"/> <!-- Generates <mapping class="hello.Message" /> in hibernate.cfg.xml -->


Chapter 5 Section 5.1 P192.
Second bullet should mention use of sql union to tie things together with 5.1.2 heading on P195. Correlation not obvious at a glance.
Third bullet. "Table per class hierarchy"/ section heading for 5.1.3 (P199)..
Maybe this is just me, but without something like "Single Table for all classes", the heading conjures up a different image to the text that follows. "Table per class hierarchy" at first sight infers multiple tables. Am I alone in this observation?

Chapter 6 P246. Reference to Using Placeholders...
Mentions 3.3.4.3. Now this would be excellent if book took heading levels down to that level of precision, but I think you'd do better saying 3.3.4 "Using placeholders" (on P135). Initially I thought you meant two sections of book. 3.3 & 4.3!
(Ditto 4.4.1.3 bottom of P 347, ref to p182)

P 256. 6.3.1
First example.
How does Hibernate infer both columns make the composite key? Is it because of HashSet?

P 345 Inverse joined properties.
Use case is unclear. Needs fleshing out.. Daily Billing file. This just contains prior days totals and gets cleared out each night right? Hence no date to restrict on. Total gets set how? Highest of reserve or highest bid...(Open payments? End date not yet passed?).. I know this is not a book on business rules, but this is too open ended for my taste. Need something more concrete to work from to grasp concept..

P428 Section 9.5.1 Quote "If you work with one database you don't need to declare the name of the persistence unit for injection". I beg to differ. I seem to remember being burnt by not specifying one in JBoss AS 4.2.2GA when doing some examples in Beginning Java EE5. Had to put unitname on @PersistenceContext annotation. Only had one value in my persistence.xml file. So I guess this it depends on App Server implementation. Book doesn't emphasise this...

P443 url update
www.jboss.com/products/transactions..
Now http://www.jboss.org/jbosstm/

P584 Switching to additional selects section fetch="select" and corresponding SQL does not make sense. I smell a rat!
Would appreciate a posting of proper SQL corresponding to section description...

P637
escape = '\'.
Remove this from example line. Move to an escape character ('\') in sentence above perhaps. Makes it look like it's part of example as is!

P647
Last exampel beginning Query q = session..
Suddenly selection criteria has gone. Slight disconnect as it.
Not major but distracting.
Ditto P648.

P649.
Can you elaborate on left join example containing 'With' clause?
Am I correct in assuming resultset will contain Items without bids as well as Items with bids that have an amount > 100
(& descripion like %foo)?

P660
Correlate example. Would be good to elaborate.
Eg:Correlated:Inner select creates user id/count pairs. Outer select joins on user and says 10 < 3 reject 10 < 10 reject 10 < 11 accept. Hence more than 10...
Was making my head spin trying to figure this out...

P688
Quote "Finally note that the JPA specification doesn't require that name parameter binding is supported for native SQL queries".
Uh? God this is a clumsy sentence!

P700 Listing 16.1
if (MaxBidAmount.compareTo(bidAmount) > 0) {
// Forward to error page
}
(Ditto P705 "Bid to low exception")
Hmm.. I'd have thought if new bid amount was equal to current max bid, initial bidder should win. Hence >= 0 seems more appropriate to me.

P716
HibernateDAOFactory
It would have made more sense to me if the inline stuff had begun with ItemDAOHibernate. Then had .... It tool me a coupe of minutes to work out what was going on. You just implemented last two because of the way they were implemented in abstract class. But since there weren't even some .... (dots) didn't grasp immediately..

P717
DAOFactory factory = DAOFactory.instance(DAOFactory.HIBERNATE);
Can you explain this line.. Specifically what is DAOFactory.HIBERNATE?
Is it some sort of constant that refers to HibernateDAOFactory class name?
Ditton P723

P734 Clover url
www.cenqua.com/clover
Redirects to new place
http://www.atlassian.com/software/clover/

P776/7 Couldn't get my head around diagram Fig 17.6/7.
Havve seen similar diagram for JSF state, but part where it crosses over to Seam didn't make sense. Maybe it's just me! (Understand concept of context resolution, but calls across from JSF state invoke app/render response baffled me somewhat).

P777 Tip. Could do with forward reference to p813 for debug...

Have to say overall, I really enjoyed your book. Last couple of chapters were awesome. Had to plough through an awful lot of reference detail to get there! Would have liked to have seen more of a dialog between the example code and material throughtout the book, but can comprehend the vast amount of information you had to convey. Fantastic job overall.
I'll leave a five star comment on Amazon.co.uk for you.
Looking at Seam/TestNG has really sparked my interest too. Already had book on latter. It's gone up in priority on my reading list. Have to invest in some more books on Seam now! Also I have to say you've resolved a lot of issues I'd had with JSF with Seam. Great job guys.

BTW:I'd like to get a firmer grasp of the technical details on how Seam handles back button/seperate browser window. Would like to know how the extra contexts were implemented too. Do you have any extra resources you can point me to?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.