@@ -15,7 +15,6 @@ import com.beeproduced.bee.persistent.blaze.processor.codegen.BeePersistentDSLCo
15
15
import com.beeproduced.bee.persistent.blaze.processor.codegen.BeePersistentDSLCodegen.PoetConstants.VALUE_PATH
16
16
import com.beeproduced.bee.persistent.blaze.processor.info.ColumnProperty
17
17
import com.beeproduced.bee.persistent.blaze.processor.info.EntityInfo
18
- import com.beeproduced.bee.persistent.blaze.processor.info.Property
19
18
import com.beeproduced.bee.persistent.blaze.processor.info.RepoInfo
20
19
import com.beeproduced.bee.persistent.blaze.processor.utils.SubProperty
21
20
import com.beeproduced.bee.persistent.blaze.processor.utils.viewColumnsWithSubclasses
@@ -26,6 +25,7 @@ import com.squareup.kotlinpoet.*
26
25
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
27
26
import com.squareup.kotlinpoet.ksp.toTypeName
28
27
import com.squareup.kotlinpoet.ksp.writeTo
28
+ import org.gradle.configurationcache.extensions.capitalized
29
29
30
30
/* *
31
31
*
@@ -278,7 +278,7 @@ class BeePersistentDSLCodegen(
278
278
path : String = "",
279
279
visitedEmbeddedViews : MutableMap <String , String ?> = mutableMapOf(),
280
280
sort : Boolean = false,
281
- ): String = run {
281
+ ): TypeSpec . Builder {
282
282
283
283
val (allRelations, allColumns)
284
284
= viewColumnsWithSubclasses(entityView, views)
@@ -288,6 +288,10 @@ class BeePersistentDSLCodegen(
288
288
viewDSL.addPath(column, path, sort)
289
289
}
290
290
291
+ for (column in embedded) {
292
+ viewDSL.addPath(column, path, sort)
293
+ }
294
+
291
295
for ((simpleName, subRelation) in allRelations) {
292
296
val innerView = views.entityViews.getValue(subRelation.relationView)
293
297
if (innerView.isExtended) continue
@@ -305,17 +309,17 @@ class BeePersistentDSLCodegen(
305
309
addType(innerDSL.build())
306
310
}
307
311
308
-
309
- " "
312
+ return this
310
313
}
311
314
312
315
private fun TypeSpec.Builder.addPath (
313
316
subProperty : SubProperty , path : String ,
314
- sort : Boolean
317
+ sort : Boolean , embeddedPropertyName : String? = null
315
318
) {
316
319
val column = subProperty.property
317
- val inner = column.innerValue
320
+ val propertyName = embeddedPropertyName ? : column.simpleName
318
321
val newPath = buildPath(path, column.simpleName, subProperty.subView)
322
+ val inner = column.innerValue
319
323
if (inner != null ) {
320
324
val innerType = inner.type.toTypeName().copy(nullable = false )
321
325
val columnType = column.type.toTypeName().copy(nullable = false )
@@ -324,7 +328,7 @@ class BeePersistentDSLCodegen(
324
328
else poetMap.classMapping(VALUE_EXP ).parameterizedBy(columnType, innerType)
325
329
val pathType = poetMap.classMapping(VALUE_PATH )
326
330
327
- val pathProperty = PropertySpec .builder(column.simpleName , interfaceType)
331
+ val pathProperty = PropertySpec .builder(propertyName , interfaceType)
328
332
.initializer(CodeBlock .Builder ()
329
333
.addStatement(" %T(%S, %T::class)" , pathType, newPath, columnType)
330
334
.build()
@@ -337,12 +341,20 @@ class BeePersistentDSLCodegen(
337
341
poetMap.classMapping(SORTABLE_EXP ).parameterizedBy(columnType)
338
342
else poetMap.classMapping(EXP ).parameterizedBy(columnType)
339
343
val pathType = poetMap.classMapping(PATH )
340
- val pathProperty = PropertySpec .builder(column.simpleName , interfaceType)
344
+ val pathProperty = PropertySpec .builder(propertyName , interfaceType)
341
345
.initializer(CodeBlock .Builder ()
342
346
.addStatement(" %T(%S)" , pathType, newPath)
343
347
.build()
344
348
)
345
349
addProperty(pathProperty.build())
350
+
351
+ val embedded = column.embedded ? : return
352
+ for (embeddedColumn in embedded.jpaProperties) {
353
+ val columnProp = ColumnProperty (embeddedColumn.declaration, embeddedColumn.type, embeddedColumn.annotations, null , null )
354
+ val embeddedSubProperty = SubProperty (columnProp)
355
+ val overrideName = " $propertyName${embeddedColumn.simpleName.capitalized()} "
356
+ addPath(embeddedSubProperty, newPath, sort, overrideName)
357
+ }
346
358
}
347
359
348
360
private fun buildPath (path : String , simpleName : String , subView : String? ): String {
0 commit comments