Skip to content

Commit bc5641b

Browse files
committed
Fix new issues introduced when fixing #934
1 parent a66c331 commit bc5641b

File tree

6 files changed

+69
-5
lines changed

6 files changed

+69
-5
lines changed

project/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
group=org.babyfish.jimmer
2-
version=0.9.58
2+
version=0.9.59

project/jimmer-core/src/main/java/org/babyfish/jimmer/meta/impl/ImmutablePropImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,9 @@ private void resolveManyToManyViewBaseProp() {
806806
deeperProp +
807807
"\" and \"" +
808808
middleProp +
809-
"\""
809+
"\", please specify \"deeperProp\" of \"" +
810+
ManyToManyView.class.getName() +
811+
"\" explicitly"
810812
);
811813
}
812814
deeperProp = middleProp;

project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/JSqlClientImpl.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.databind.ObjectMapper;
44
import org.babyfish.jimmer.impl.util.ClassCache;
5+
import org.babyfish.jimmer.impl.util.Classes;
56
import org.babyfish.jimmer.lang.OldChain;
67
import org.babyfish.jimmer.meta.*;
78
import org.babyfish.jimmer.sql.association.meta.AssociationProp;
@@ -49,6 +50,8 @@
4950
import org.slf4j.LoggerFactory;
5051

5152
import java.lang.reflect.Type;
53+
import java.math.BigDecimal;
54+
import java.math.BigInteger;
5255
import java.sql.Connection;
5356
import java.sql.SQLException;
5457
import java.time.ZoneId;
@@ -1185,13 +1188,19 @@ private void addScalarProviderImpl(ImmutableProp prop, ScalarProvider<?, ?> scal
11851188
"please use property-specific scalar provider"
11861189
);
11871190
}
1188-
if (ReaderManager.isStandardScalarType((Class<?>) scalarType)) {
1191+
if (Classes.primitiveTypeOf((Class<?>) scalarType).isPrimitive() ||
1192+
scalarType == String.class ||
1193+
scalarType == BigInteger.class ||
1194+
scalarType == BigDecimal.class
1195+
) {
11891196
throw new IllegalStateException(
11901197
"Illegal global type scalar provider type \"" +
11911198
scalarProvider.getClass().getName() +
11921199
"\" its scalar type argument cannot be \"" +
11931200
scalarType +
1194-
"\" because it is standard type. Please " +
1201+
"\" because it is " +
1202+
(scalarType == String.class ? "string" : "numeric") +
1203+
". Please " +
11951204
"use non-standard type or " +
11961205
"use property level scalar provider"
11971206
);

project/jimmer-sql/src/test/java/org/babyfish/jimmer/sql/model/link/Course.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,10 @@ public interface Course {
2323
@ManyToManyView(prop = "learningLinks", deeperProp = "student")
2424
// or @ManyToManyView(prop = "learningLinks")
2525
List<Student> students();
26+
27+
@OneToMany(mappedBy = "nextCourse")
28+
List<CourseDependency> prevCourseDependencies();
29+
30+
@ManyToManyView(prop = "prevCourseDependencies", deeperProp = "prevCourse")
31+
List<Course> prevCourses();
2632
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.babyfish.jimmer.sql.model.link;
2+
3+
import org.babyfish.jimmer.sql.*;
4+
5+
@Entity
6+
public interface CourseDependency {
7+
8+
@Id
9+
@GeneratedValue(strategy = GenerationType.IDENTITY)
10+
long id();
11+
12+
@ManyToOne
13+
@OnDissociate(DissociateAction.DELETE)
14+
Course nextCourse();
15+
16+
@ManyToOne
17+
@OnDissociate(DissociateAction.DELETE)
18+
Course prevCourse();
19+
20+
String reason();
21+
}

project/jimmer-sql/src/test/resources/database.sql

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ drop table worker if exists;
3131
drop table category if exists;
3232
drop table post if exists;
3333
drop table learning_link if exists;
34+
drop table course_dependency if exists;
3435
drop table course if exists;
3536
drop table student if exists;
3637
drop table ms_product if exists;
@@ -835,6 +836,29 @@ alter table learning_link
835836
add constraint uq_course
836837
unique(student_id, course_id);
837838

839+
create table course_dependency(
840+
id bigint auto_increment(100) not null,
841+
prev_course_id bigint not null,
842+
next_course_id bigint not null,
843+
reason varchar(50) not null
844+
);
845+
alter table course_dependency
846+
add constraint pk_course_dependency
847+
primary key(id);
848+
alter table course_dependency
849+
add constraint uq_course_dependency
850+
unique(prev_course_id, next_course_id);
851+
alter table course_dependency
852+
add constraint fk_course_dependency__prev
853+
foreign key(prev_course_id)
854+
references course(id)
855+
on delete cascade;
856+
alter table course_dependency
857+
add constraint fk_course_dependency__next
858+
foreign key(next_course_id)
859+
references course(id)
860+
on delete cascade;
861+
838862
insert into student(id, name) values(1, 'Oakes');
839863
insert into student(id, name) values(2, 'Roach');
840864
insert into course(id, name, academic_credit) values(1, 'Java', 2);
@@ -845,7 +869,9 @@ insert into learning_link(id, student_id, course_id, score) values
845869
(2, 1, 3, null),
846870
(3, 2, 3, 87),
847871
(4, 2, 1, null);
848-
872+
insert into course_dependency(prev_course_id, next_course_id, reason) values
873+
(3, 1, 'JDBC requires SQL'),
874+
(1, 2, 'Kotlin depends on JVM');
849875

850876

851877

0 commit comments

Comments
 (0)