getJavaType() {
+ return type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.data.relational.repository.query.RelationalEntityMetadata#getTableName()
+ */
+ public String getTableName() {
+ return tableEntity.getTableName();
+ }
+}
diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/repository/query/package-info.java b/spring-data-relational/src/main/java/org/springframework/data/relational/repository/query/package-info.java
new file mode 100755
index 00000000..ccd616a6
--- /dev/null
+++ b/spring-data-relational/src/main/java/org/springframework/data/relational/repository/query/package-info.java
@@ -0,0 +1,7 @@
+/**
+ * Query support for relational database repositories.
+ */
+@NonNullApi
+package org.springframework.data.relational.repository.query;
+
+import org.springframework.lang.NonNullApi;
diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/repository/support/MappingRelationalEntityInformation.java b/spring-data-relational/src/main/java/org/springframework/data/relational/repository/support/MappingRelationalEntityInformation.java
new file mode 100755
index 00000000..10d795c4
--- /dev/null
+++ b/spring-data-relational/src/main/java/org/springframework/data/relational/repository/support/MappingRelationalEntityInformation.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2018 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.relational.repository.support;
+
+import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
+import org.springframework.data.relational.repository.query.RelationalEntityInformation;
+import org.springframework.data.repository.core.support.PersistentEntityInformation;
+import org.springframework.lang.Nullable;
+
+/**
+ * {@link RelationalEntityInformation} implementation using a {@link RelationalPersistentEntity} instance to lookup the
+ * necessary information. Can be configured with a custom table name.
+ *
+ * Entity types that do not declare an explicit Id type fall back to {@link Long} as Id type.
+ *
+ * @author Mark Paluch
+ */
+public class MappingRelationalEntityInformation extends PersistentEntityInformation
+ implements RelationalEntityInformation {
+
+ private final RelationalPersistentEntity entityMetadata;
+ private final @Nullable String customTableName;
+ private final Class fallbackIdType;
+
+ /**
+ * Creates a new {@link MappingRelationalEntityInformation} for the given {@link RelationalPersistentEntity}.
+ *
+ * @param entity must not be {@literal null}.
+ */
+ public MappingRelationalEntityInformation(RelationalPersistentEntity entity) {
+ this(entity, null, null);
+ }
+
+ /**
+ * Creates a new {@link MappingRelationalEntityInformation} for the given {@link RelationalPersistentEntity} and
+ * fallback identifier type.
+ *
+ * @param entity must not be {@literal null}.
+ * @param fallbackIdType can be {@literal null}.
+ */
+ public MappingRelationalEntityInformation(RelationalPersistentEntity entity, @Nullable Class fallbackIdType) {
+ this(entity, null, fallbackIdType);
+ }
+
+ /**
+ * Creates a new {@link MappingRelationalEntityInformation} for the given {@link RelationalPersistentEntity} and
+ * custom table name.
+ *
+ * @param entity must not be {@literal null}.
+ * @param customTableName can be {@literal null}.
+ */
+ public MappingRelationalEntityInformation(RelationalPersistentEntity entity, String customTableName) {
+ this(entity, customTableName, null);
+ }
+
+ /**
+ * Creates a new {@link MappingRelationalEntityInformation} for the given {@link RelationalPersistentEntity},
+ * collection name and identifier type.
+ *
+ * @param entity must not be {@literal null}.
+ * @param customTableName can be {@literal null}.
+ * @param idType can be {@literal null}.
+ */
+ @SuppressWarnings("unchecked")
+ private MappingRelationalEntityInformation(RelationalPersistentEntity entity, @Nullable String customTableName,
+ @Nullable Class idType) {
+
+ super(entity);
+
+ this.entityMetadata = entity;
+ this.customTableName = customTableName;
+ this.fallbackIdType = idType != null ? idType : (Class) Long.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.data.relational.repository.query.RelationalEntityInformation#getTableName()
+ */
+ public String getTableName() {
+ return customTableName == null ? entityMetadata.getTableName() : customTableName;
+ }
+
+ public String getIdAttribute() {
+ return entityMetadata.getRequiredIdProperty().getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.data.repository.core.support.PersistentEntityInformation#getIdType()
+ */
+ @Override
+ public Class getIdType() {
+
+ if (this.entityMetadata.hasIdProperty()) {
+ return super.getIdType();
+ }
+
+ return fallbackIdType;
+ }
+}
diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/repository/support/package-info.java b/spring-data-relational/src/main/java/org/springframework/data/relational/repository/support/package-info.java
new file mode 100755
index 00000000..28aeb251
--- /dev/null
+++ b/spring-data-relational/src/main/java/org/springframework/data/relational/repository/support/package-info.java
@@ -0,0 +1,7 @@
+/**
+ * Support infrastructure for query derivation of relational database repositories.
+ */
+@NonNullApi
+package org.springframework.data.relational.repository.support;
+
+import org.springframework.lang.NonNullApi;