Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 565 Vote(s) - 3.45 Average
  • 1
  • 2
  • 3
  • 4
  • 5
org.hibernate.AnnotationException: No identifier specified for entity - even when it was

#1
I have the following configuration:

<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="jpaDataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.example.domain</value>
<value>com.example.repositories</value>
</list>
</property>
</bean>

I have my Geoname class in com.example.domain:

@Entity
@Table(name="geonames")
public class Geoname implements Serializable {

@Id
@Column(name="geonameid")
private Long geonameid = null;
}

yet, when running, I get the following exception:

> Caused by: org.hibernate.AnnotationException: No identifier specified
> for entity: com.example.domain.Geoname at
> org.hibernate.cfg.InheritanceState.determineDefaultAccessType(InheritanceState.java:277)
> at
> org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:224)
> at
> org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:664)
> at
> org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3449)
> at
> org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3403)
> at
> org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1330)
> at
> org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1730)

Any ideas why?

side note: I am combining both mongodb and hibernate/ mysql on this project.
Reply

#2
try this


@Column(name="geonameid",unique=true,nullable=false)
Reply

#3
I had the following

import org.springframework.data.annotation.Id;


Naturally, it should be:

import javax.persistence.Id;

Thanks to @JB Nizet
Reply

#4
I faced the same error.I solved it and figured out i didn't put @Id annotations in id field in my Entity class.

@Entity
@Table(name="geonames")
public class Geoname implements Serializable {

@Column(name="geonameid")
private Long geonameid = null;
}
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through