@OneToOne getting returned as ManyToOneType

▼魔方 西西 提交于 2019-12-04 18:44:21

That's much clearer now, thank you.

Is it really SampleBean1 in both cases (e.g. entity itself and the OneToOne mapped property) or is it a typo? If they are the same, I'm pretty sure it's illegal (how do you imagine that mapping would work)? I'm a bit surprised it's quietly downgraded to "many-to-one" instead of throwing an error, but perhaps that's what Hibernate Annotations mapper does.

More a possibility

        if (propertyType.isEntityType()) {
            EntityType entityType = (EntityType) propertyType;

            if (entityType instanceof ManyToOneType) {
                System.out.println("this is ManyToOne");
            } else if(entityType instanceof OneToOneType) {
                System.out.println("this is OneToOne");
            }
        }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!