update the publisher name

2 posts / 0 new
Last post
update the publisher name

It looks like, there is no way to update the publisher name in the site as it is.

the problem is,

I  modified the XHTML file and have an ipunt text with value of #{publisher.name}  and added the following code to the Update method in publisher bean:

if (name!= null && !name.equals(publisher.name)) {publisher.setName(name)}

but it keeps giving me:

EntityNotFoundException( "The publisher with name "  " was not found)

The publisher's name property

The publisher's name property is the primary key. In the Publisher class, the update method first checks if there is a publisher for the given name, and if not it creates the error message which you get now (code lines 196-200). If you like to update the primary key property value(s), then you'll have to disable this check. Our code is written so that the primary key property is readonly, which normally is the case. Notice that if you like to update a primary key property value, in some cases, you have to take care of the foreign key dependencies (most of them are automatically performed by the database engine if the ON UPDATE CASCADE clause is used when the corresponding database tables are created).