Hibernate exception : cannot simultaneously fetch multiple bags

Problem

Exception class : org.hibernate.loader.MultipleBagFetchException
Exception : cannot simultaneously fetch multiple bags

Solution

Use @LazyCollection(LazyCollectionOption.FALSE) rather than fetch=FetchType.EAGER
Annotation @LazyCollection(LazyCollectionOption.FALSE) makes that collecion is loaded like with FetchType.EAGER and you can use it on two and more collections.

Example

Initial Code : Works with lazy fetch type

public class WitrEntity{

    private Set witrEntityLabels = new HashSet(0);

    [...]

    @OneToMany(fetch=FetchType.LAZY, mappedBy="witrEntity")
    public Set getWitrEntityLabels() {
        return this.witrEntityLabels;
    }

}

public class WitrEntityLabel{

    private WitrEntity witrEntity;

    [...]

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="WITR_ENTITY_ID", nullable=false, insertable=false, updatable=false)
    public WitrEntity getWitrEntity() {
        return this.witrEntity;
    }

}

Wrong manipulation : wanna set fetch type to eager

public class WitrEntity{

    private Set witrEntityLabels = new HashSet(0);

    [...]

    @OneToMany(fetch=FetchType.EAGER, mappedBy="witrEntity") // THIS IS THE CAUSE OF EXCEPTION
    public Set getWitrEntityLabels() {
        return this.witrEntityLabels;
    }

}

public class WitrEntityLabel{

    private WitrEntity witrEntity;

    [...]

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="WITR_ENTITY_ID", nullable=false, insertable=false, updatable=false)
    public WitrEntity getWitrEntity() {
        return this.witrEntity;
    }

}

Solution : if you want to force loading collection

public class WitrEntity{

    private Set witrEntityLabels = new HashSet(0);

    [...]

    @OneToMany(mappedBy="witrEntity") // delete fetch=FetchType.LAZY
    @LazyCollection(LazyCollectionOption.FALSE) // add use @LazyCollection false
    public Set getWitrEntityLabels() {
        return this.witrEntityLabels;
    }
}

exception: Can’t connect to X11 window server using ‘:0’ as the value of the DISPLAY variable


=========================================== 30/05/2013
If you have following error: Can’t connect to X11 window server using ‘:0’ as the value of the DISPLAY variable.
you must know that :
– linux user (launching process requsting Xserver) is not authorized to access Xserver
– OR DISPLAY variable is bad configured

type xhost to know:

> xhost
No protocol specified
No protocol specified
xhost:  unable to open display “???”
==> means you don’t have authorization to any Xserver
==> to authorize access type: > sudo xhost +SI:localuser:youruser

> xhost
xhost:  unable to open display “???”
==> means DISPLAY variable is bad configured
==> you must fix DISPLAY variable. type: > export DISPLAY=hostname:D.S
– hostname is the name of the computer where the X server runs. An omitted hostname means the localhost.
– D is a sequence number (usually 0). It can be varied if there are multiple displays connected to one computer.
– S is the screen number. A display can actually have multiple screens. Usually there’s only one screen though where 0 is the default.

oracle: exception : Ora-28001: the password has expired

May 6, 2013

this error tell us that user password has expired. check this with following request:
SELECT USERNAME, PROFILE, ACCOUNT_STATUS, EXPIRY_DATE FROM dba_users WHERE username=’your_oracle_username’;
value of ACCOUNT_STATUS column (expired or expired&locked)

password policies are defined in oracle PROFILE associated to user (value of PROFILE column). profile properties can be found here:
select * from dba_profiles where profile = ‘profile_name’;

take a look of line : resource_name =’PASSWORD_LIFE_TIME’ and depending on your security policies you can change the value to UNLIMITED to avoid password expiry