I am trying to take a bean with the comment but it is not working. I wonder why ? Here's my code snippet:
Configurable App Content Consultant CONTENT = createContext ("context.xml"); // Find all @Entities sections with map beans Annnotation = suggestorContext.getBeansWithAnnotation (Entity.class);
My map size is 0 !!!!
Here is my context.xml file:
& lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Bem xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: tx = "http: // Www. Springframework.org/schema/tx "xmlns: jpa =" http://www.springframework.org/schema/data/jpa "xmlns: reference =" http://www.springframework.org/schema/context "Xsi: Schema Location = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx Http : //www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/ Spring - jpa.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> & Lt; Bean id = "ISMDS" class = "org.springframework.jdbc.datasource.DriverManagerDataSource" & gt; & Lt; Property Name = "driverClassName" value = "com.mysql.jdbc.Driver" /> & Lt; Property Name = "User Name" Value = "User" /> & Lt; Property Name = "Password" Value = "Password" /> & Lt; Property Name = "url" value = "jdbc: mysql: // localhost: 3306 / mydb" /> & Lt; / Bean & gt; & Lt; Bean id = "myEmf" class = "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" & gt; & Lt; Property Name = "Data Source" Riff = "ISMDS" /> & Lt; Property Name = "JPAVENDER Adapter" & gt; & Lt; Bean square = "org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" & gt; & Lt; Property Name = "Show SQL" value = "False" /> & Lt; Property Name = "DatabasePlatform" Value = "org.hibernate.dialect.MySQL5InnoDBDialect" /> & Lt; Property Name = "Generated DDL" value = "False" /> & Lt; / Bean & gt; & Lt; / Property & gt; & Lt; Property Name = "packagesToScan" value = "com.myproject.entities.entity" /> & Lt; / Bean & gt; & Lt; Bean id = "Transaction manager" class = "org.springframework.orm.jpa.JpaTransactionManager" & gt; & Lt; Property Name = "entityManagerFactory" ref = "myEmf" /> & Lt; / Bean & gt; & Lt; Tx: annotation-driven transaction-manager = "transaction manager" /> & Lt; Bean class = "org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /> & Lt; Bean class = "org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> & Lt; Jpa: repository base-package = "com.mypackage.dao" unit-manager-factory-riff = "my amf" /> & Lt; / Bean & gt;
All of my entities are in the following package: com.myproject.entities.entity
What's wrong?
This does not work, because getBeansWithNnotation (Entity.class) of spring;
Only spring beans, but the general body is not a spring bean, so it works now.
Probably there is no way in JPA / Hibernate to get all the map class (classes are not institution examples!).
Some annotations have been discussed here to find all the sections: In one of the answers, a script called "" has been mentioned. I used this device some time ago and it worked well.
Comments
Post a Comment