下面列出了javax.persistence.OrderBy#org.hibernate.annotations.Fetch 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@OneToMany(mappedBy="timingLocation",fetch = FetchType.EAGER)
@Fetch(FetchMode.SELECT)
@Cascade(CascadeType.DELETE)
public List<TimingLocationInput> getInputs() {
//return associatedSplits.sorted((Split o1, Split o2) -> o1.getPosition().compareTo(o2.getPosition()));
return timingInputList;
}
@ElementCollection(fetch = FetchType.EAGER)
@OneToMany(mappedBy="raceAward",cascade={CascadeType.PERSIST, CascadeType.REMOVE},fetch = FetchType.EAGER)
@Fetch(FetchMode.SELECT)
@OrderColumn(name = "category_priority")
public List<AwardCategory> getAwardCategories(){
return awardCategories;
}
@OneToMany(mappedBy="race",cascade={CascadeType.PERSIST, CascadeType.REMOVE},fetch = FetchType.EAGER)
@OrderBy("split_seq_number")
@Fetch(FetchMode.SELECT)
public List<Split> getSplits() {
return raceSplitList;
//return raceSplits.sorted((Split o1, Split o2) -> o1.getPosition().compareTo(o2.getPosition()));
}
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "jobData")
@Fetch(FetchMode.SELECT)
@BatchSize(size = 10)
@MapKey(name = "jobId")
@PrimaryKeyJoinColumn(name = "JOB_ID")
public List<JobContent> getJobContent() {
return jobContent;
}
@Override
@Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
@OneToMany(targetEntity = Policy.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "guarantee_term_id", referencedColumnName = "id", nullable = true)
public List<IPolicy> getPolicies() {
return policies;
}
@Override
@Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
@OneToMany(targetEntity = Violation.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "guarantee_term_id", referencedColumnName = "id", nullable = true)
public List<IViolation> getViolations() {
return violations;
}
@Override
@Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
@OneToMany(targetEntity = Penalty.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "guarantee_term_id", referencedColumnName = "id", nullable = true)
public List<IPenalty> getPenalties() {
return penalties;
}
@Override
@Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
@OneToMany(targetEntity = Breach.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "violation_id", referencedColumnName = "id", nullable = true)
public List<IBreach> getBreaches() {
return breaches;
}
protected static void defineFetchingStrategy(ToOne toOne, XProperty property) {
LazyToOne lazy = property.getAnnotation( LazyToOne.class );
Fetch fetch = property.getAnnotation( Fetch.class );
ManyToOne manyToOne = property.getAnnotation( ManyToOne.class );
OneToOne oneToOne = property.getAnnotation( OneToOne.class );
FetchType fetchType;
if ( manyToOne != null ) {
fetchType = manyToOne.fetch();
}
else if ( oneToOne != null ) {
fetchType = oneToOne.fetch();
}
else {
throw new AssertionFailure(
"Define fetch strategy on a property not annotated with @OneToMany nor @OneToOne"
);
}
if ( lazy != null ) {
toOne.setLazy( !( lazy.value() == LazyToOneOption.FALSE ) );
toOne.setUnwrapProxy( ( lazy.value() == LazyToOneOption.NO_PROXY ) );
}
else {
toOne.setLazy( fetchType == FetchType.LAZY );
toOne.setUnwrapProxy( false );
}
if ( fetch != null ) {
if ( fetch.value() == org.hibernate.annotations.FetchMode.JOIN ) {
toOne.setFetchMode( FetchMode.JOIN );
toOne.setLazy( false );
toOne.setUnwrapProxy( false );
}
else if ( fetch.value() == org.hibernate.annotations.FetchMode.SELECT ) {
toOne.setFetchMode( FetchMode.SELECT );
}
else if ( fetch.value() == org.hibernate.annotations.FetchMode.SUBSELECT ) {
throw new AnnotationException( "Use of FetchMode.SUBSELECT not allowed on ToOne associations" );
}
else {
throw new AssertionFailure( "Unknown FetchMode: " + fetch.value() );
}
}
else {
toOne.setFetchMode( getFetchMode( fetchType ) );
}
}
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 ) );
}
}
@OneToMany(mappedBy="race",cascade={CascadeType.PERSIST, CascadeType.REMOVE},fetch = FetchType.EAGER)
@Fetch(FetchMode.SELECT)
public List<Wave> getWaves() {
return raceWavesList;
}
@OneToMany(mappedBy="race",cascade={CascadeType.PERSIST, CascadeType.REMOVE},fetch = FetchType.EAGER)
@Fetch(FetchMode.SELECT)
public List<RaceReport> getRaceReports() {
return raceReportsList;
}
@OneToMany(mappedBy="raceReport",cascade={CascadeType.PERSIST, CascadeType.REMOVE},fetch = FetchType.LAZY)
@Fetch(FetchMode.SELECT)
public List<RaceOutputTarget> getRaceOutputTargets() {
return raceOutputTargetList;
}
@Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
@OneToMany(targetEntity = Variable.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "service_properties_id", referencedColumnName = "id", nullable = true)
public List<IVariable> getVariableSet() {
return variableSet;
}
@Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
@OneToMany(targetEntity = Template.class, fetch = FetchType.EAGER)
@JoinColumn(name = "provider_id", referencedColumnName = "id", nullable = true)
public List<ITemplate> getTemplates() {
return templates;
}
@Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
@OneToMany(targetEntity = ServiceProperties.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "agreement_id", referencedColumnName = "id", nullable = true)
public List<IServiceProperties> getServiceProperties() {
return serviceProperties;
}
@Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
@OneToMany(targetEntity = GuaranteeTerm.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "agreement_id", referencedColumnName = "id", nullable = true)
public List<IGuaranteeTerm> getGuaranteeTerms() {
return guaranteeTerms;
}