Annotations in the head of the entity?
piero May 13, 2005 5:40 AMhello,
i have to define an entity like this:
public class Address implements Serializable { private long id; private String blah; ... @Id(generate = GeneratorType.AUTO) public long getId() { return id; } public void setId(long id) { this.id = id; } ... }
in many tutorials the following syntax is used, which is - i think - much easier. one important point is code generation - eclipse for example generates the getters and setters for me - i just have to look at the top of the class to see everything i need when it comes to relations etc.
public class Address implements Serializable { @Id(generate = GeneratorType.AUTO) private long id; private String blah; ... //getters and setters ... }
you use this syntax in some of your examples here in the forum. maybe just to reduce the code size.. dont know. if i try it, it comes to an null pointer exception:
java.lang.NullPointerException at org.hibernate.mapping.PersistentClass.createPrimaryKey(PersistentClass.java:266) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:442) at org.hibernate.cfg.AnnotationConfiguration.addAnnotatedClass(AnnotationConfiguration.java:94) at org.hibernate.cfg.AnnotationConfiguration.addAnnotatedClasses(AnnotationConfiguration.java:62) at org.jboss.ejb3.entity.HibernateSessionFactory.createSessionFactory(HibernateSessionFactory.java:196) at org.jboss.ejb3.Ejb3Module.createHibernateSessionFactory(Ejb3Module.java:256) at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:263) at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272) at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80) at org.jboss.mx.server.Invocation.invoke(Invocation.java:72) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644) at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:897) at $Proxy0.start(Unknown Source) at org.jboss.system.ServiceController.start(ServiceController.java:418) at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80) at org.jboss.mx.server.Invocation.invoke(Invocation.java:72) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177) at $Proxy16.start(Unknown Source) at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:166) at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738) at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80) at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:121) at org.jboss.mx.server.Invocation.invoke(Invocation.java:74) at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127) at org.jboss.mx.server.Invocation.invoke(Invocation.java:74) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177) at $Proxy8.deploy(Unknown Source) at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:325) at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:483) at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204) at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:215) at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
sorry if this is nothing new. its hard to find information like this in the forum or jira. is this planned in future releases, is it something that should work already or is it just something that will never come?