Skip to content

Add conditionals to joinTable column mapping #14621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
neilabdev opened this issue Mar 22, 2017 · 1 comment
Open

Add conditionals to joinTable column mapping #14621

neilabdev opened this issue Mar 22, 2017 · 1 comment

Comments

@neilabdev
Copy link

Thanks for the great work! Just a hope for a future enhancement. But basically, it would be nice to be able to add conditions to a joinTable, based on instance values or hard coded values on column names. I've used it in rails several times, and my projects where I use Grails mostly, the ability is sorely missed. See example below:

class Employee {
    static hasMany = [projects: Project]

    static mapping = {
        projects joinTable: [name: 'EMP_PROJ',
                             column: 'PROJECT_ID',
                             key: 'EMPLOYEE_ID', where: {->
            [type_column: this.some_discriminator_column_of_this_instance]
        }
    }
}
@graemerocher
Copy link
Contributor

Not sure if this is possible with Hibernate. I know there is a sql mapping you can apply to columns.. so that may be the way to do this.

jamesfredley referenced this issue in apache/grails-data-mapping Mar 13, 2025
Use org.glassfish jaxb instead of com.sun to avoid duplicate jar
@jdaugherty jdaugherty transferred this issue from apache/grails-data-mapping Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants