Skip to content

Commit f6d1169

Browse files
committed
add 'testing/testing-typed-ids-spring-data-indexed'
1 parent 03a448a commit f6d1169

19 files changed

+1080
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
plugins {
2+
id("framefork.java")
3+
}
4+
5+
dependencies {
6+
implementation(project(":typed-ids-hibernate-63"))
7+
8+
api(platform("org.springframework.boot:spring-boot-dependencies:3.4.5"))
9+
api("org.springframework.boot:spring-boot-starter-data-jpa")
10+
11+
annotationProcessor(project(":typed-ids-index-java-classes-processor"))
12+
testAnnotationProcessor(project(":typed-ids-index-java-classes-processor"))
13+
14+
testImplementation(project(":typed-ids-hibernate-63-testing"))
15+
testImplementation("org.springframework.boot:spring-boot-starter-test")
16+
testImplementation("org.springframework.boot:spring-boot-testcontainers")
17+
testImplementation("org.testcontainers:junit-jupiter")
18+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package org.framefork.typedIds.bigint.springData;
2+
3+
import jakarta.persistence.Column;
4+
import jakarta.persistence.Entity;
5+
import jakarta.persistence.Table;
6+
import org.framefork.typedIds.bigint.ObjectBigIntId;
7+
8+
@Entity
9+
@Table(name = BigIntAppGeneratedExplicitMappingEntity.TABLE_NAME)
10+
public class BigIntAppGeneratedExplicitMappingEntity
11+
{
12+
13+
public static final String TABLE_NAME = "bigint_app_generated_explicit_mapping";
14+
15+
@jakarta.persistence.Id
16+
@Column(nullable = false)
17+
private Id id;
18+
19+
@Column(nullable = false)
20+
private String title;
21+
22+
public BigIntAppGeneratedExplicitMappingEntity(final String title)
23+
{
24+
this.id = Id.random();
25+
this.title = title;
26+
}
27+
28+
@SuppressWarnings("NullAway")
29+
protected BigIntAppGeneratedExplicitMappingEntity()
30+
{
31+
}
32+
33+
public Id getId()
34+
{
35+
return id;
36+
}
37+
38+
public String getTitle()
39+
{
40+
return title;
41+
}
42+
43+
public static final class Id extends ObjectBigIntId<Id>
44+
{
45+
46+
private Id(final long inner)
47+
{
48+
super(inner);
49+
}
50+
51+
public static Id random()
52+
{
53+
return ObjectBigIntId.randomBigInt(Id::new);
54+
}
55+
56+
public static Id from(final String value)
57+
{
58+
return ObjectBigIntId.fromString(Id::new, value);
59+
}
60+
61+
public static Id from(final long value)
62+
{
63+
return ObjectBigIntId.fromLong(Id::new, value);
64+
}
65+
66+
}
67+
68+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.framefork.typedIds.bigint.springData;
2+
3+
import org.springframework.data.jpa.repository.JpaRepository;
4+
import org.springframework.stereotype.Repository;
5+
6+
@Repository
7+
public interface BigIntAppGeneratedExplicitMappingEntityRepository extends JpaRepository<BigIntAppGeneratedExplicitMappingEntity, BigIntAppGeneratedExplicitMappingEntity.Id>
8+
{
9+
10+
BigIntAppGeneratedExplicitMappingEntity findByTitle(String title);
11+
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package org.framefork.typedIds.bigint.springData;
2+
3+
import jakarta.persistence.Column;
4+
import jakarta.persistence.Entity;
5+
import jakarta.persistence.GeneratedValue;
6+
import jakarta.persistence.GenerationType;
7+
import jakarta.persistence.Table;
8+
import org.framefork.typedIds.bigint.ObjectBigIntId;
9+
import org.jspecify.annotations.Nullable;
10+
11+
@Entity
12+
@Table(name = BigIntDbAutoGeneratedExplicitMappingEntity.TABLE_NAME)
13+
public class BigIntDbAutoGeneratedExplicitMappingEntity
14+
{
15+
16+
public static final String TABLE_NAME = "bigint_db_auto_generated_explicit_mapping";
17+
18+
@jakarta.persistence.Id
19+
@GeneratedValue(strategy = GenerationType.AUTO)
20+
@Column(nullable = false)
21+
@Nullable
22+
private Id id;
23+
24+
@Column(nullable = false)
25+
private String title;
26+
27+
public BigIntDbAutoGeneratedExplicitMappingEntity(final String title)
28+
{
29+
this.title = title;
30+
}
31+
32+
@SuppressWarnings("NullAway")
33+
protected BigIntDbAutoGeneratedExplicitMappingEntity()
34+
{
35+
}
36+
37+
@Nullable
38+
public Id getId()
39+
{
40+
return id;
41+
}
42+
43+
public String getTitle()
44+
{
45+
return title;
46+
}
47+
48+
public static final class Id extends ObjectBigIntId<Id>
49+
{
50+
51+
private Id(final long inner)
52+
{
53+
super(inner);
54+
}
55+
56+
public static Id random()
57+
{
58+
return ObjectBigIntId.randomBigInt(Id::new);
59+
}
60+
61+
public static Id from(final String value)
62+
{
63+
return ObjectBigIntId.fromString(Id::new, value);
64+
}
65+
66+
public static Id from(final long value)
67+
{
68+
return ObjectBigIntId.fromLong(Id::new, value);
69+
}
70+
71+
}
72+
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.framefork.typedIds.bigint.springData;
2+
3+
import org.springframework.data.jpa.repository.JpaRepository;
4+
import org.springframework.stereotype.Repository;
5+
6+
@Repository
7+
public interface BigIntDbAutoGeneratedExplicitMappingEntityRepository extends JpaRepository<BigIntDbAutoGeneratedExplicitMappingEntity, BigIntDbAutoGeneratedExplicitMappingEntity.Id>
8+
{
9+
10+
BigIntDbAutoGeneratedExplicitMappingEntity findByTitle(String title);
11+
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package org.framefork.typedIds.bigint.springData;
2+
3+
import jakarta.persistence.Column;
4+
import jakarta.persistence.Entity;
5+
import jakarta.persistence.GeneratedValue;
6+
import jakarta.persistence.GenerationType;
7+
import jakarta.persistence.Table;
8+
import org.framefork.typedIds.bigint.ObjectBigIntId;
9+
import org.jspecify.annotations.Nullable;
10+
11+
@Entity
12+
@Table(name = BigIntDbIdentityGeneratedExplicitMappingEntity.TABLE_NAME)
13+
public class BigIntDbIdentityGeneratedExplicitMappingEntity
14+
{
15+
16+
public static final String TABLE_NAME = "bigint_db_identity_generated_explicit_mapping";
17+
18+
@jakarta.persistence.Id
19+
@GeneratedValue(strategy = GenerationType.IDENTITY)
20+
@Column(nullable = false)
21+
@Nullable
22+
private Id id;
23+
24+
@Column(nullable = false)
25+
private String title;
26+
27+
public BigIntDbIdentityGeneratedExplicitMappingEntity(final String title)
28+
{
29+
this.title = title;
30+
}
31+
32+
@SuppressWarnings("NullAway")
33+
protected BigIntDbIdentityGeneratedExplicitMappingEntity()
34+
{
35+
}
36+
37+
@Nullable
38+
public Id getId()
39+
{
40+
return id;
41+
}
42+
43+
public String getTitle()
44+
{
45+
return title;
46+
}
47+
48+
public static final class Id extends ObjectBigIntId<Id>
49+
{
50+
51+
private Id(final long inner)
52+
{
53+
super(inner);
54+
}
55+
56+
public static Id random()
57+
{
58+
return ObjectBigIntId.randomBigInt(Id::new);
59+
}
60+
61+
public static Id from(final String value)
62+
{
63+
return ObjectBigIntId.fromString(Id::new, value);
64+
}
65+
66+
public static Id from(final long value)
67+
{
68+
return ObjectBigIntId.fromLong(Id::new, value);
69+
}
70+
71+
}
72+
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.framefork.typedIds.bigint.springData;
2+
3+
import org.springframework.data.jpa.repository.JpaRepository;
4+
import org.springframework.stereotype.Repository;
5+
6+
@Repository
7+
public interface BigIntDbIdentityGeneratedExplicitMappingEntityRepository extends JpaRepository<BigIntDbIdentityGeneratedExplicitMappingEntity, BigIntDbIdentityGeneratedExplicitMappingEntity.Id>
8+
{
9+
10+
BigIntDbIdentityGeneratedExplicitMappingEntity findByTitle(String title);
11+
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package org.framefork.typedIds.bigint.springData;
2+
3+
import jakarta.persistence.Column;
4+
import jakarta.persistence.Entity;
5+
import jakarta.persistence.GeneratedValue;
6+
import jakarta.persistence.GenerationType;
7+
import jakarta.persistence.Table;
8+
import org.framefork.typedIds.bigint.ObjectBigIntId;
9+
import org.jspecify.annotations.Nullable;
10+
11+
@Entity
12+
@Table(name = BigIntDbSequenceGeneratedExplicitMappingEntity.TABLE_NAME)
13+
public class BigIntDbSequenceGeneratedExplicitMappingEntity
14+
{
15+
16+
public static final String TABLE_NAME = "bigint_db_sequence_generated_explicit_mapping";
17+
18+
@jakarta.persistence.Id
19+
@GeneratedValue(strategy = GenerationType.SEQUENCE)
20+
@Column(nullable = false)
21+
@Nullable
22+
private Id id;
23+
24+
@Column(nullable = false)
25+
private String title;
26+
27+
public BigIntDbSequenceGeneratedExplicitMappingEntity(final String title)
28+
{
29+
this.title = title;
30+
}
31+
32+
@SuppressWarnings("NullAway")
33+
protected BigIntDbSequenceGeneratedExplicitMappingEntity()
34+
{
35+
}
36+
37+
@Nullable
38+
public Id getId()
39+
{
40+
return id;
41+
}
42+
43+
public String getTitle()
44+
{
45+
return title;
46+
}
47+
48+
public static final class Id extends ObjectBigIntId<Id>
49+
{
50+
51+
private Id(final long inner)
52+
{
53+
super(inner);
54+
}
55+
56+
public static Id random()
57+
{
58+
return ObjectBigIntId.randomBigInt(Id::new);
59+
}
60+
61+
public static Id from(final String value)
62+
{
63+
return ObjectBigIntId.fromString(Id::new, value);
64+
}
65+
66+
public static Id from(final long value)
67+
{
68+
return ObjectBigIntId.fromLong(Id::new, value);
69+
}
70+
71+
}
72+
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.framefork.typedIds.bigint.springData;
2+
3+
import org.springframework.data.jpa.repository.JpaRepository;
4+
import org.springframework.stereotype.Repository;
5+
6+
@Repository
7+
public interface BigIntDbSequenceGeneratedExplicitMappingEntityRepository extends JpaRepository<BigIntDbSequenceGeneratedExplicitMappingEntity, BigIntDbSequenceGeneratedExplicitMappingEntity.Id>
8+
{
9+
10+
BigIntDbSequenceGeneratedExplicitMappingEntity findByTitle(String title);
11+
12+
}

0 commit comments

Comments
 (0)