sábado, 26 de janeiro de 2013

Could not determine type for [..] at table [..] for columns [..]

Oi, hoje tive o erro abaixo ao iniciar minha aplicação EJB no JBoss 6

13:57:23,368 INFO [org.hibernate.validator.engine.resolver.DefaultTraversableResolver] Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
13:57:23,380 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=test-ear-1.0.0.ear/test-ejb-1.0.0.jar#l8 state=Create: javax.persistence.PersistenceException: [PersistenceUnit: test] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:900) [:3.5.5-Final]
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74) [:3.5.5-Final]
at org.jboss.jpa.builder.DefaultCEMFBuilder.build(DefaultCEMFBuilder.java:47) [:1.0.2-alpha-1]


[...]

at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]
Caused by: org.hibernate.MappingException: Could not determine type for: br.com.localhost8080.test.company.Company, at table: MY_TABLE, for columns: [org.hibernate.mapping.Column(company)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:291) [:3.5.5-Final]
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:275) [:3.5.5-Final]
at org.hibernate.mapping.Property.isValid(Property.java:217) [:3.5.5-Final]

O Problema era que eu tinha uma coluna mapeada assim:

@JoinColumn(name = "ID_COMPANY", nullable = false)
private Company company;

Mas ela precisa do @ManyToOne

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ID_COMPANY", nullable = false)
private Company company;

Ao fazer dessa forma funcionou normalmente : )

Vaaleu!!
Adriano Schmidt