-->
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: Can I apply cascade in an @Any relationship?
PostPosted: Tue Oct 19, 2010 6:25 pm 
Newbie

Joined: Sat Mar 06, 2010 1:19 pm
Posts: 8
Hi,

I have an @Any relationship, like the below:

Code:

public class Customer {
         
        private String name;

        ...other attributes

@Any(metaColumn = @Column(name = "type")) 
   @AnyMetaDef(idType = "long", metaType = "string", metaValues = { 
   @MetaValue(value = "Personal", targetEntity = Personal.class), 
   @MetaValue(value = "Business", targetEntity = Business.class) }) 
   @JoinColumn(name = "codeType")
   private CustomerType type;

}
[*]

When I'm trying to persist the customer.
There is an error:
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing

Can I apply a cascade to the @Any to avoid persist the CustomerType?


Top
 Profile  
 
 Post subject: Re: Can I apply cascade in an @Any relationship?
PostPosted: Wed Aug 16, 2017 11:01 pm 
Newbie

Joined: Wed Aug 16, 2017 10:49 pm
Posts: 1
I know it's an old post, but it's one of the first posts that appears when searching for
Code:
"@Any" cascade
on Google. So:

It's possible to use Cascade with @Any relationship by using @Cascade. It's also possible to use ToMany relationships using @ManyToAny annotation.


Top
 Profile  
 
 Post subject: Re: Can I apply cascade in an @Any relationship?
PostPosted: Thu Aug 17, 2017 2:09 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
Yes, you can. Check out this User Guide example for more details.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


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.