Hi
Following examples I did:
Code:
@Entity
@Table(name = "periodos")
public class Periodos implements Serializable {
@OneToMany(fetch = FetchType.EAGER)
@JoinTable(
name="PeriodosHorarios",
joinColumns = { @JoinColumn( name="id_per") },
inverseJoinColumns = @JoinColumn( name="id_horarios")
)
/**
* Id del periodo.
*/
private int id_per;
/** Used to join tables */
private Set<Horarios> periodosHorarios;
public Set<Horarios> getPeriodosHorarios() {
return periodosHorarios;
}
public void setPeriodosHorarios(Set<Horarios> periodosHorarios) {
this.periodosHorarios = periodosHorarios;
}
and
Code:
@Entity
@Table(name = "horarios")
public class Horarios implements Serializable {
/**
* PK.
*/
private int id_horarios;
/**
* FK to periodos.
*/
private int id_per;
@Column(name = "id_per", nullable = false, unique = false)
public int getId_per() {
return id_per;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public int getId_horarios() {
return id_horarios;
}
But when I start my application I get the error:
Code:
17:35:27,250 ERROR [ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'sessionFactory' defined in ServletContext resource [/WEB-INF/application
Context-dao.xml]: Invocation of init method failed; nested exception is org.hibe
rnate.MappingException: Could not determine type for: java.util.Set, for columns
: [org.hibernate.mapping.Column(periodosHorarios)]
Caused by:
org.hibernate.MappingException: Could not determine type for: java.util.Set, for
columns: [org.hibernate.mapping.Column(periodosHorarios)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.Property.isValid(Property.java:185)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:4
10)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1099)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1284)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSession
Factory(LocalSessionFactoryBean.java:804)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessi
onFactory(LocalSessionFactoryBean.java:744)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPr
opertiesSet(AbstractSessionFactoryBean.java:131)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1085)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:429)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:250)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:141)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:247)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:161)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:270)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:346)
at org.springframework.web.context.support.AbstractRefreshableWebApplica
tionContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
at org.springframework.web.context.ContextLoader.createWebApplicationCon
text(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationConte
xt(ContextLoader.java:184)
at org.springframework.web.context.ContextLoaderListener.contextInitiali
zed(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
t.java:3763)
Why this error ?? I did what I understood from samples...
Thanks in advance
C