org.hibernate.annotations.LazyCollectionOption Java Examples
The following examples show how to use
org.hibernate.annotations.LazyCollectionOption.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: User.java From aws-photosharing-example with Apache License 2.0 | 5 votes |
@XmlTransient @LazyCollection(LazyCollectionOption.EXTRA) @ManyToMany(fetch=FetchType.LAZY, cascade=CascadeType.ALL) @JoinTable(name = "role_mappings", joinColumns = { @JoinColumn(name = "user_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "role", nullable = false, updatable = false) }) public List<Role> getRoles() {return _roles;}
Example #2
Source File: Album.java From aws-photosharing-example with Apache License 2.0 | 4 votes |
@OneToMany(mappedBy = "album") @LazyCollection(LazyCollectionOption.EXTRA) public List<Comment> getComments() {return comment;}
Example #3
Source File: Album.java From aws-photosharing-example with Apache License 2.0 | 4 votes |
@OneToMany(mappedBy = "album", orphanRemoval=true) @LazyCollection(LazyCollectionOption.EXTRA) public List<Share> getShares() {return shares;}
Example #4
Source File: Album.java From aws-photosharing-example with Apache License 2.0 | 4 votes |
@XmlTransient @LazyCollection(LazyCollectionOption.EXTRA) @ManyToMany(fetch = FetchType.LAZY, mappedBy = "albums", cascade=CascadeType.PERSIST) public List<Media> getMedia() {return media;}
Example #5
Source File: User.java From aws-photosharing-example with Apache License 2.0 | 4 votes |
@XmlTransient @LazyCollection(LazyCollectionOption.EXTRA) @OneToMany(mappedBy = "user", orphanRemoval=true, fetch=FetchType.LAZY, cascade=CascadeType.ALL) public List<Media> getMedia() {return media;}
Example #6
Source File: User.java From aws-photosharing-example with Apache License 2.0 | 4 votes |
@XmlTransient @LazyCollection(LazyCollectionOption.EXTRA) @OneToMany(mappedBy = "user", orphanRemoval=true, fetch=FetchType.LAZY, cascade=CascadeType.ALL) public List<Share> getShares() {return shares;}
Example #7
Source File: User.java From aws-photosharing-example with Apache License 2.0 | 4 votes |
@XmlTransient @LazyCollection(LazyCollectionOption.EXTRA) @OneToMany(mappedBy = "user", orphanRemoval=true, fetch=FetchType.LAZY, cascade=CascadeType.ALL) public List<Album> getAlbums() {return albums;}
Example #8
Source File: Role.java From aws-photosharing-example with Apache License 2.0 | 4 votes |
@XmlTransient @LazyCollection(LazyCollectionOption.EXTRA) @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy="roles") public Set<User> getUsers() {return this._users;}
Example #9
Source File: Media.java From aws-photosharing-example with Apache License 2.0 | 4 votes |
@OneToMany(mappedBy = "media") @LazyCollection(LazyCollectionOption.EXTRA) public List<Comment> getComments() {return comment;}
Example #10
Source File: Media.java From aws-photosharing-example with Apache License 2.0 | 4 votes |
@OneToMany(mappedBy = "media", orphanRemoval=true) @LazyCollection(LazyCollectionOption.EXTRA) public List<Share> getShares() {return shares;}
Example #11
Source File: CollectionBinder.java From lams with GNU General Public License v2.0 | 4 votes |
private void defineFetchingStrategy() { LazyCollection lazy = property.getAnnotation( LazyCollection.class ); Fetch fetch = property.getAnnotation( Fetch.class ); OneToMany oneToMany = property.getAnnotation( OneToMany.class ); ManyToMany manyToMany = property.getAnnotation( ManyToMany.class ); ElementCollection elementCollection = property.getAnnotation( ElementCollection.class ); ManyToAny manyToAny = property.getAnnotation( ManyToAny.class ); FetchType fetchType; if ( oneToMany != null ) { fetchType = oneToMany.fetch(); } else if ( manyToMany != null ) { fetchType = manyToMany.fetch(); } else if ( elementCollection != null ) { fetchType = elementCollection.fetch(); } else if ( manyToAny != null ) { fetchType = FetchType.LAZY; } else { throw new AssertionFailure( "Define fetch strategy on a property not annotated with @ManyToOne nor @OneToMany nor @CollectionOfElements" ); } if ( lazy != null ) { collection.setLazy( !( lazy.value() == LazyCollectionOption.FALSE ) ); collection.setExtraLazy( lazy.value() == LazyCollectionOption.EXTRA ); } else { collection.setLazy( fetchType == FetchType.LAZY ); collection.setExtraLazy( false ); } if ( fetch != null ) { if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) { collection.setFetchMode( FetchMode.JOIN ); collection.setLazy( false ); } else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) { collection.setFetchMode( FetchMode.SELECT ); } else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) { collection.setFetchMode( FetchMode.SELECT ); collection.setSubselectLoadable( true ); collection.getOwner().setSubselectLoadableCollections( true ); } else { throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() ); } } else { collection.setFetchMode( AnnotationBinder.getFetchMode( fetchType ) ); } }