import com.xxx.entity.CompanyEntity;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface CompanyRepository extends Neo4jRepository<CompanyEntity,Long> {
@Query("MATCH (c:Company) WHERE c.CompanyName CONTAINS $name RETURN c")
List<CompanyEntity> findSearchResults(@Param("name") String name);
@Query("MATCH p=(n:Company)-[r:RELATION]-() WHERE n.CompanyName CONTAINS $name RETURN collect(p)")
List<CompanyEntity> findCompanyEntityByCompanyName(@Param("name") String name);
}
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Property;
import org.springframework.data.neo4j.core.schema.Relationship;
import java.util.ArrayList;
import java.util.List;
@Node("Company")
@Data
@AllArgsConstructor
@RequiredArgsConstructor
@ToString
public class CompanyEntity {
@Id
@GeneratedValue
private Long id;
@Property("CompanyCode")
private String companyCode;
@Property("CompanyName")
private String companyName;
@Relationship(type = "RELATION", direction = Relationship.Direction.INCOMING)
public List<InvestorEntity> teammates = new ArrayList<>();
@Relationship(type = "RELATION", direction = Relationship.Direction.INCOMING)
public List<InvestmentOrgEntity> orgs = new ArrayList<>();
}
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Property;
@Node("Investor")
@Data
@AllArgsConstructor
@RequiredArgsConstructor
@ToString
public class InvestorEntity {
@Id
@GeneratedValue
private Long id;
@Property("InvestorCode")
private String investorCode;
@Property("InvestorName")
private String investorName;
}
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Property;
@Node("InvestmentOrg")
@Data
@AllArgsConstructor
@RequiredArgsConstructor
@ToString
public class InvestmentOrgEntity {
@Id
@GeneratedValue
private Long id;
@Property("InvestmentOrgCode")
private String investmentOrgCode;
@Property("InvestmentOrgName")
private String investmentOrgName;
}