(Partent -> Child -> Child) not able to model with JpaContext MapStruct - mapstruct

With JpaContext Class logic, We are not able to model the Parent->child1->child2 relation. Mapstruct generated implemented class logic works only if both child1 and child2 are the children of the Parent. Any suggestions

Related

EF Core: ignore base class on table inheritance

I'm trying to use the Fluent API to use the TPH for mapping an existing class hierarchy into a single table. In this case, I've got a base class (holds common properties) and then 2 concrete classes that extend the base class with its own properties:
class Base
{
// properties
}
class A: Base {}
class B: Base {}
I'm trying to map the classes to the tables by using a custom type configurator and I thought that I could do it like this:
class BaseConfigurator: IEntityTypeConfiguration<Base>
{
public void Configure(EntityTypeBuilder<Base> builder)
{
builder.ToTable("...");
// more mappings
builder.HasDescriminator(e => e.Type)
.HasValue<A>("A")
.HasValue<B>("B");
}
}
When I try to run the code, I get an error message which says that the base type is part of the hierarchy, but does not have a discriminator value configured.
Since the base type is abstract and it's there only to be save the common properties, how can I say that the base type should be ignored?
Thanks.
Just noticed that I'm missing the abstract qualifier from the base class declaration...adding it seems to solve the problem.

Can we inherit Ktable from parent class to child class?

We have a requirement to reuse KTable(Gender) in multiple classes by inheriting from parent class but when we create inheritance linkage then it shows an error Topic has already been registered by another source
I am passing builder parameter from singleton object.
How could it can be possible in seperate two classes?
object app{
def main{
builder properties .....
new Parent(builder).test()
new child(builder).testing()
}
}
Class Parent(builder : StreamBuilder) {
val gender : KTable = ........
}
Class child(builder : StreamBuilder) extends Parent(builder){
gender.tostream.peek((k,v) => println(v))
}

Why Parent class is allowing to Child class to make Parent class's methods as abstract in Child class?

class Parent
{
def m1()
{
System.out.println("m1 method");
}
}
abstract class Child extends Parent
{
def m1()
}
The above code compiles succesfully, and my question is:
Why does the Parent class allow the Child class to make the m1() method as an abstract method?
Where would we use this kind of scenario?
Now it can so happen that you want to create multiple variation of the parent class. Now Parent class being a concrete class it is very hard to achieve that. Because you can either try to make the parent as abstract and then provide implementation. But if the concrete class is used in several places of your big code base you have little choice but to go as follows.
Hence the strategy is to create abstract child it goes as follows
abstract class Child extends Parent
{
def m1()
}
class SpecialChild extends Child {
//.. some implementation of m1
}
Now we can still use the original child
child = new SpecialChild();
Hope this makes sense.

Create a child class's instance in parent class's method

abstract class Parent {
def filter(p: Parent => Boolean): Parent = filterAcc(p, new Child)
}
class Child extends Parent {
// ...
}
I am working on Scala tutorial and wondering how the following can be possible.
There are two classes Parent and Child. The Parent class creates an instance of child in the method filter.
How can a parent class refer to a child class which inherits the parent class?
That is no contradiction. If parent and child are defined within the same compilation unit, then the parent can refer to its sub-class, both symbols/types are known to each other.

How can I override a parent method in coffeescript while still being able to call the parent

I have two coffeescript classes something like this. In the base view model I have a method that I want to override in the child that inherits from the base view model.
class exports.BaseViewModel
constructor: () ->
someBaseMethod: =>
console.log "I'm doing the base stuff"
class ChildViewModel extends BaseViewModel
constructor: () ->
someBaseMethod: =>
#doSomethingFirst()
super #someBaseMethod()
This isn't working as is because the line super #someBaseMethod() calls itself creating an infinite loop.
Is it possible to achieve what I want here?
Yes, call super just like it was a function (it represents a reference to the superclass version of the method you're in):
class ChildViewModel extends BaseViewModel
constructor: ->
someBaseMethod: =>
#doSomethingFirst()
super()