You are right (as usually grrr ;-) ). Maybe constraint for this case
would be fine. In manual isn't explained what happen if opposite side
is !aggregateRoot. It should be also constrained that relation
many-to-many to !aggregateRoot is senseless.
>
> The problem is that in the hbm file <set is defined.
>
> I looked in the code generation template and for manyToManyReference there
> is:
> LET getCollectionType() == "bag" ? "bag" : "set" AS collection
>
> I would guess that for many-to-many it doesn't make sense to use an ordered
> List. We should probably have a constraint error on this case.
>
> Probably you would like a one-to-many instead. You do that by adding
> reference in Employee to OrgUnit and define opposite, i.e. make the
> association bidirectional.
> If you don't want bidirectional, you can keep it as is but add the inverse
> keyword.
> This is described in
>
http://fornax.itemis.de/confluence/display/fornax/3.+Advanced+Tutorial+(CSC)#3.AdvancedTutorial(CSC)-Collections>
> /Patrik
>
>
> PaloT wrote:
>>
>> Hello,
>> in my project following error is raised. I don't know why Set is
>> expected because everywhere List is declared. I'm using 1.5. Any idea?
>>
>> TNX
>>
>> STACK TRACE:
>> java.lang.ClassCastException: java.util.ArrayList cannot be cast to
>> java.util.Set
>> at org.hibernate.type.SetType.wrap(SetType.java:39)
>> at
>> org.hibernate.event.def.WrapVisitor.processArrayOrNewCollection(WrapVisitor.java:84)
>> at
>> org.hibernate.event.def.WrapVisitor.processCollection(WrapVisitor.java:51)
>> at
>> org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101)
>> at org.hibernate.event.def.WrapVisitor.processValue(WrapVisitor.java:98)
>> at
>> org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55)
>> at
>> org.hibernate.event.def.DefaultFlushEntityEventListener.wrapCollections(DefaultFlushEntityEventListener.java:192)
>> at
>> org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:125)
>> at
>> org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
>> at
>> org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
>> at
>> org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
>> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
>> at
>> org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:390)
>> at
>> org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:105)
>> at
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
>> at
>> org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor.invoke(ThrowsAdviceInterceptor.java:126)
>> at
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
>> at
>> org.fornax.cartridges.sculptor.framework.errorhandling.ServiceContextStoreAdvice.invoke(ServiceContextStoreAdvice.java:39)
>> at
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
>> at
>> org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
>> at
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
>> at
>> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
>> at $Proxy9.save(Unknown Source)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:597)
>> at sk.f4s.pic.web.server.ScServlet.handleRequest(ScServlet.java:348)
>>
>> DESIGN:
>> Entity OrgUnit {
>> scaffold
>> String name key length="30";
>> - @OrgUnitKind orgUnitKind nullable;
>> - @Employee boss nullable;
>> - List<@Employee> employee;
>> - @OrgUnit parent nullable;
>> }
>>
>> HBM.XML:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping
>> DTD//EN" "
http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>>
>> <hibernate-mapping>
>> <class name="sk.f4s.pic.org.domain.OrgUnit" table="ORGUNIT">
>> <id name="id">
>> <generator class="native"/>
>> </id>
>> <version name="version" type="java.lang.Long"/>
>> <!-- <natural-id> There is a BUG HHH-1569 that prevents us from
>> using <natural-id> -->
>> <property name="name" length="30" not-null="true" unique="true"/>
>> <!-- </natural-id> -->
>> <property name="createdDate" type="timestamp"/>
>> <property name="createdBy" length="50"/>
>> <property name="lastUpdated" type="timestamp"/>
>> <property name="lastUpdatedBy" length="50"/>
>> <many-to-one name="orgUnitKind" column="ORGUNITKIND"
>> class="sk.f4s.pic.org.domain.OrgUnitKind" cascade="all"/>
>> <many-to-one name="boss" column="BOSS"
>> class="sk.f4s.pic.org.domain.Employee" cascade="all"/>
>> <many-to-one name="parent" column="PARENT"
>> class="sk.f4s.pic.org.domain.OrgUnit" cascade="all"/>
>> <set name="employee" table="EMPLOYEE_ORGUNIT" cascade="all">
>> <key column="ORGUNIT"/>
>> <many-to-many column="EMPLOYEE"
>> class="sk.f4s.pic.org.domain.Employee"/>
>> </set>
>> </class>
>> </hibernate-mapping>
>>
>>
>> BASE:
>> public abstract class OrgUnitBase extends AbstractDomainObject
>> implements Auditable {
>> private Long id;
>> private String name;
>> private Date createdDate;
>> private String createdBy;
>> private Date lastUpdated;
>> private String lastUpdatedBy;
>> private Long version;
>> private OrgUnitKind orgUnitKind;
>> private Employee boss;
>> private OrgUnit parent;
>> private List<Employee> employee = new ArrayList<Employee>();
>>
>> protected OrgUnitBase() {
>> }
>>
>> public OrgUnitBase(@Name("name")
>> String name) {
>> super();
>> Validate.notNull(name);
>> this.name = name;
>> }
>>
>> public Long getId() {
>> return id;
>> }
>>
>> /**
>> * The id is not intended to be changed or assigned manually, but
>> * for test purpose it is allowed to assign the id.
>> */
>> protected void setId(Long id) {
>> if ((this.id != null) && !this.id.equals(id)) {
>> throw new IllegalArgumentException(
>> "Not allowed to change the id property.");
>> }
>> this.id = id;
>> }
>>
>> public String getName() {
>> return name;
>> }
>>
>> @SuppressWarnings("unused")
>> private void setName(String name) {
>> if ((this.name != null) && !this.name.equals(name)) {
>> throw new IllegalArgumentException(
>> "Not allowed to change the name property.");
>> }
>> this.name = name;
>> }
>>
>> public Date getCreatedDate() {
>> return createdDate;
>> }
>>
>> public void setCreatedDate(Date createdDate) {
>> this.createdDate = createdDate;
>> }
>>
>> public String getCreatedBy() {
>> return createdBy;
>> }
>>
>> public void setCreatedBy(String createdBy) {
>> this.createdBy = createdBy;
>> }
>>
>> public Date getLastUpdated() {
>> return lastUpdated;
>> }
>>
>> public void setLastUpdated(Date lastUpdated) {
>> this.lastUpdated = lastUpdated;
>> }
>>
>> public String getLastUpdatedBy() {
>> return lastUpdatedBy;
>> }
>>
>> public void setLastUpdatedBy(String lastUpdatedBy) {
>> this.lastUpdatedBy = lastUpdatedBy;
>> }
>>
>> public Long getVersion() {
>> return version;
>> }
>>
>> public void setVersion(Long version) {
>> this.version = version;
>> }
>>
>> public OrgUnitKind getOrgUnitKind() {
>> return orgUnitKind;
>> }
>>
>> public void setOrgUnitKind(OrgUnitKind orgUnitKind) {
>> this.orgUnitKind = orgUnitKind;
>> }
>>
>> public Employee getBoss() {
>> return boss;
>> }
>>
>> public void setBoss(Employee boss) {
>> this.boss = boss;
>> }
>>
>> public OrgUnit getParent() {
>> return parent;
>> }
>>
>> public void setParent(OrgUnit parent) {
>> this.parent = parent;
>> }
>>
>> public List<Employee> getEmployee() {
>> return employee;
>> }
>>
>> @SuppressWarnings("unused")
>> private void setEmployee(List<Employee> employee) {
>> this.employee = employee;
>> }
>>
>> /**
>> * This method is used by equals and hashCode.
>> * @return {@link #getName}
>> */
>> public Object getKey() {
>> return getName();
>> }
>> }
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Fornax-developer mailing list
>>
Fornax-developer@...
>>
https://lists.sourceforge.net/lists/listinfo/fornax-developer>>
>>
>
> --
> View this message in context:
http://www.nabble.com/Problem-tp24193872s17564p24197846.html> Sent from the Fornax-Platform mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Fornax-developer mailing list
>
Fornax-developer@...
>
https://lists.sourceforge.net/lists/listinfo/fornax-developer>