Hi,

In SpringBoot 1 TypeAlias("name") does work as expected but if I migrate to SpringBoot 2 it doesn't instantiate the classes correctly.

@Document(collection = "test")
@TypeAlias("y")
public class TestY extends Test {

    private String y;

    public String getY() {
        return y;
    }

    public void setY(String y) {
        this.y = y;
    }
}

@Document(collection = "test")
public class Test {
    @Id
    protected String id;

    public Test() {
        this.id = id;
    }
}

@Document(collection = "test")
@TypeAlias("x")
public class TestX extends Test {

    private String x;

    public String getX() {
        return x;
    }

    public void setX(String x) {
        this.x = x;
    }
}

Executions:

If I only load the instances -> Test instances should be TestX or TestY but they are all Test

List<Test> test = testRepository.findAll();

If I save before the entities -> Test instances after loading are instantiated right as TestX and TestY

        TestY y = new TestY();
        y.setY("y");
        testRepository.save(y);

        TestX x = new TestX();
        x.setX("x");
        testRepository.save(x);
        List<Test> test = testRepository.findAll();

 ```

In Spring Boot 1 it works as expected.

**Dependencies**

before: spring-boot-starter-data-mongodb-1.5.21.RELEASE

after: spring-boot-starter-data-mongodb-2.1.11.RELEASE

**Repositories**

@Repository public interface TestRepository extends MongoRepository {

} ```

Comment From: wilkinsona

To avoid wasting people’s time, please do not cross-post. I can see that someone is already trying to help you on Stack Overflow. The functionality that you are asking about is provided by Spring Data MongoDB. You may want to update your question’s tags accordingly.

Comment From: mawasource

@wilkinsona The problem is - that this functionality is provided by Spring Data MongoDB but doesn't work accordingly. I posted a question at stackoverflow but it seems to be that it is a bug instead of a question.

Edit: I deleted the question on stackoverflow. In my description is the behavior described what does not work in spring boot 1 but not in spring boot 2

Comment From: snicoll

@mawasource deleting your SO question isn't going to reopen this issue I am afraid. It's a shame considering someone was trying to help you.

Comment From: mawasource

@snicoll I deleted the question because my intention is not to ask bugreports at stackoverflow. To extend this report - I additionally generated an empty project with default configuration and this issue is still there. I'm sorry if creating a question/issue was a "misleading" bevhavior - but isn't it possible that a question results into a bugreport?

Comment From: wilkinsona

@mawasource If you believe you have found a bug in Spring Data MongoDB, please open an issue with a test case that reproduces the problem.

A question can result in a bug report, but it's important to let things run their course on Stack Overflow. Deleting a question while someone was in the middle of trying to help you is a waste of their time.

Comment From: mawasource

@wilkinsona Ah okay - so I'm in the wrong project. Sorry for that. I've undeleted the question and I will open an issue in the mongodb project.