-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: @ElementCollection + Enumerated
PostPosted: Mon Mar 07, 2011 2:45 pm 
Newbie

Joined: Mon Mar 07, 2011 2:37 pm
Posts: 3
I'm using ElementCollection annotation, but i can't make it work, looks like hibernate is not processing it.

My code

@Entity(name = "user")
public class User implements Serializable {

private static final long serialVersionUID = 5791136125077815304L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String username;
private String password;
private String mail;
private Date createdOn;

@ElementCollection
@Column(name = "authority")
@CollectionTable(name = "user_authority", joinColumns = @JoinColumn(name = "user_id"))
@Enumerated(EnumType.ORDINAL)
private List<AuthorityEnum> authorityList;
...

public enum AuthorityEnum {
ROLE_ADMIN,
ROLE_USER;

public int getId() {
return ordinal();
}
}

I tried several different things, but every time i save a User i only can see the insert referred to user table, nothing about authorities.

I'm using hibernate 3.6.1-Final, hibernate-commons-annotations-3.2.0-Final, hibernate-jpa-2.0-api-1.0.0-Final, atomikos 3.7.0 and spring 3.0.4 under jetty-8.0.0.M2.

Any clue?


Top
 Profile  
 
 Post subject: Re: @ElementCollection + Enumerated
PostPosted: Tue Mar 22, 2011 12:53 pm 
Newbie

Joined: Mon Mar 07, 2011 2:37 pm
Posts: 3
Nobody had this problem? I can't solve it.


Top
 Profile  
 
 Post subject: Re: @ElementCollection + Enumerated
PostPosted: Thu Mar 31, 2011 8:26 am 
Newbie

Joined: Mon Mar 07, 2011 2:37 pm
Posts: 3
All that i could find till now is that if i change to HibernateTransactionManager it works.

This is my JTA/Atomikos configuration:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="shardedDataSource"/>
<property name="packagesToScan" value="ar.com.summerproject.socialnet.server.model"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.transaction.manager_lookup_class">
com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup
</prop>
</props>
</property>
</bean>

<!-- Construct Atomikos UserTransactionManager, needed to configure Spring -->
<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close">
<!-- when close is called, should we force transactions to terminate or not? -->
<property name="forceShutdown"><value>true</value></property>
</bean>

<!-- Also use Atomikos UserTransactionImp, needed to configure Spring -->
<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
<property name="transactionTimeout"><value>300</value></property>
</bean>

<!-- Configure the Spring framework to use JTA transactions from Atomikos -->
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager"><ref bean="atomikosTransactionManager" /></property>
<property name="userTransaction"><ref bean="atomikosUserTransaction" /></property>
</bean>

<!-- enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="transactionManager"/>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.