Announcement Announcement Module
Collapse
No announcement yet.
Scan annotated classes for eclipselink Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scan annotated classes for eclipselink

    hi all!
    first, sorry about my english!

    i have a class that scan a defined package and reads all classes, and then, add this classes to the hibernate. something like this:
    Code:
    public class AthusFactoryBean extends AnnotationSessionFactoryBean {
    	
    	//Lista dos pacotes que devem ser escaneados
    	public static final String[] PACKAGES_SCAN = new String[]{
    			"br.com.athus.modelos",
    			"br.com.athus.modelos.movimentacao"};
    	
    	@Override
    	protected SessionFactory buildSessionFactory() throws Exception {
    		ArrayList<Class<?>> classes = new ArrayList<Class<?>>();
    		
    		ClassPathScanningCandidateComponentProvider scanner = 
    			new ClassPathScanningCandidateComponentProvider(false);
    		
    		scanner.addIncludeFilter(new AnnotationTypeFilter(Entity.class));
    		scanner.addIncludeFilter(new AnnotationTypeFilter(Embeddable.class));
    
    		
    		for(String pacote : PACOTES_SCAN)
    		{
    			for (BeanDefinition bd : scanner.findCandidateComponents(pacote)) {
    				try {
    					String name = bd.getBeanClassName();
    					classes.add(Class.forName(name));
    				} catch (Exception e) {
    					System.err.println(e);
    				}
    			}
    		}
    		//Registering found classess
    		setAnnotatedClasses(classes.toArray(new Class[classes.size()]));
    		return super.buildSessionFactory();
    	}
    so, now i need to do the same on eclipselink.
    there's a way to do this?
    thanks

  • #2
    Hey, why did you have to extend the AnnotationSessionFactoryBean. Isn't following work for you?

    Code:
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    	<property name="packagesToScan">
    		<list>
    			<value>br.com.athus.modelos.**.*</value>
    		</list>
    	</property>
    </bean>

    Comment


    • #3
      yeah, i did it, but i'm not using hibernate anymore
      i'm using eclipselink

      Comment

      Working...
      X