"damianharvey" wrote : Bingo. Cheers Matt. Worked a treat. Your first
suggestion worked first time (always nice).
|
Cool
"damianharvey" wrote :
| Does anyone know what behaviour that the block of code in the Home object
is trying to avoid? ie: why not just take the class rather than throw the
exception?
|
I think perhaps you misread that code. I'll post it here for reference:
| public Class<E> getEntityClass()
| {
| if (entityClass==null)
| {
| Type type = getClass().getGenericSuperclass();
| if (type instanceof ParameterizedType)
| {
| ParameterizedType paramType = (ParameterizedType) type;
| entityClass = (Class<E>) paramType.getActualTypeArguments()[0];
| }
| else
| {
| throw new IllegalArgumentException("Could not guess entity
class by reflection");
| }
| }
| return entityClass;
| }
|
EntityHome needs to know what your entity's class is, so that it can create a
new instance when needed. What it does is check to see if you've set an entity
class (which is usually, I imagine, only done if this Home was created by xml
in components.xml). If you haven't, it tries to guess the class by looking at
the type parameter of the home instance's superclass.
In your case, the superclass wasn't EntityHome, but BookingHome, which has no
type parameter. So, it couldn't get the class and threw an exception.
Make sense?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4087681#4087681
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4087681
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user