Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Canonical model class is not working after changing the class name
Canonical model class is not working after changing the class name [message #1067495] Tue, 09 July 2013 06:08 Go to next message
Saravanan Subiramaniam is currently offline Saravanan SubiramaniamFriend
Messages: 10
Registered: April 2013
Junior Member
By default, eclipselink generates the canonical model classname which is same as the entity class name with the default suffix '_'. However, I wanted to change the generated canonical meta model class name, so I created custom CanonicalModelProcessor extending eclipselink's CanonicalModelProcessor.

For instance, my entity name is EmployeeEntity and wanted to generate meta model class as Employee_.java (instead of EmployeeEntity_.java).

So, my generated class looks like:

@Generated(value="EclipseLink-2.3.2.v20111125-r10461", date="2013-07-09T07:54:49")
@StaticMetamodel(EmployeeEntity.class)
public class Employee_ {
public static volatile SingularAttribute<EmployeeEntity, Integer> id;
}

But it looks like the meta model is initialized only if the name matches with the entity name. Because when I access Employee_.id.getName() --> it returns null. Can anyone explain this behaviour? Is it necessary for the meta model class to have the same name as that of entity name?

[Updated on: Tue, 09 July 2013 16:37]

Report message to a moderator

Re: Canonical model class is not working after changing the class name [message #1067620 is a reply to message #1067495] Tue, 09 July 2013 15:33 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
EclipseLink I believe pulls the entity class to be used with the Canonical metamodel class from the StaticMetamodel annotation. You should be specifying EmployeeEntity.class within the annotation instead of EmployeePersistable.class if that is the Entity it should be associated with.
Re: Canonical model class is not working after changing the class name [message #1067626 is a reply to message #1067620] Tue, 09 July 2013 16:36 Go to previous messageGo to next message
Saravanan Subiramaniam is currently offline Saravanan SubiramaniamFriend
Messages: 10
Registered: April 2013
Junior Member
Hi Chris,
Yes, I was specifying EmployeeEntity.class in StaticMetamodel annotation (it was a typo mistake in earlier thread).

[Updated on: Tue, 09 July 2013 16:38]

Report message to a moderator

Re: Canonical model class is not working after changing the class name [message #1067646 is a reply to message #1067626] Tue, 09 July 2013 19:30 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Try turning on logging to Finest, as you should see "Canonical Metamodel class [{0}] not found during initialization." and "Canonical Metamodel class [{0}] found and instantiated during initialization." messages logged at the Finer level under the Metamodel category. Also verify that you are calling em or emf.getMetamodel() first in case the persistence unit hasn't been fully initialized yet. If it is showing the default names are being searched for, check that the Employee_ classes can be found by the persistence unit - adding them to the persistence.xml list of classes or by ensuring the exclude-unlisted-classes tag is set to false and that they are located within the same jar as the entities so their annotations can be processed the same way.
Re: Canonical model class is not working after changing the class name [message #1073195 is a reply to message #1067646] Wed, 24 July 2013 09:47 Go to previous message
Saravanan Subiramaniam is currently offline Saravanan SubiramaniamFriend
Messages: 10
Registered: April 2013
Junior Member
Hi Chris,
It worked after adding the custom meta model class name in the persistence unit and it worked. Thanks!
Previous Topic:NullPointerException while using jaxb moxy
Next Topic:Exception [EclipseLink-6094] : The parameter name ... does not match any....
Goto Forum:
  


Current Time: Tue Apr 23 12:46:36 GMT 2024

Powered by FUDForum. Page generated in 0.02904 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top