Errata

Better, Faster, Lighter Java

Errata for Better, Faster, Lighter Java

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 142
7.3 7th Paragraph

I am getting the following problem in the code shown

class BoardManager {

Thwe code starts in paragraph 7

SessionFactory factory;

Configuration cfg;

BoardManager( ) {

try {

cfg = new Configuration( )

.addClass(discussion.User.class) // dom4j exception throw

.addClass(discussion.Topic.class)

.addClass(discussion.Post.class);

With Eclipse 3.1 and Hibernate 3.1.1 I am getting following exception

All packages and imports have been taken care (I have not explicitely inported
do4j.jar)

Exception in thread "main" java.lang.NoClassDefFoundError:
org/dom4j/DocumentException
at discussion.BoardManager.<init>(BoardManager.java:17)
at discussion.BoardManager.main(BoardManager.java:131)

Interestingly, Hibernate API shows addclass method throws Mapping exception, which
inherits from Hibernate Exception. So where is this org/dom4j/DocumentException
coming from.

Anonymous   
Printed Page 209
last part of code sample

I think this:

HashMap hits = new HashMap(qb.getResults().length);
for(...........)
{
hits.put("hits", qb.getResults()[i]);
}
return new ModelAndView("SearchProducts", hits);

should be replaced by something like:

HashMap model = new HashMap(1);
model.put("hits", Arrays.asList(qb.getResults()));
return new ModelAndView("SearchProducts", model);

Anonymous