我正在尝试使用@Query注释访问费用,其中类型是收入,通过spring(2.7.6) jpa。
终端错误:
Error creating bean with name 'expenseController': Unsatisfied dependency expressed through field 'expenseService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with n
向PostgreSQL发送普通SQL时,如下所示:
CREATE TABLE things (
id BIGINT PRIMARY KEY NOT NULL,
foo BIGINT NOT NULL,
bar BIGINT NOT NULL
);
INSERT INTO things VALUES (9900, 1, 2);
INSERT INTO things VALUES (9901, 3, 4);
INSERT INTO things VALUES (9902, 1, 4);
SELECT * FROM things WHERE fo
我在Spring中编写了这个查询方法:
@Query("SELECT MAX(TO_NUMBER(ban.codiBanca)) FROM DBanche ban WHERE LENGTH(TRIM(TRANSLATE(ban.codiBanca, '0123456789', ' '))) IS NULL")
public BigDecimal getMaxCodiBanca();
字段类型的codiBanca是VARCHAR(20)。
启动应用程序时,会获得以下错误:
Caused By: java.lang.IllegalArgumentEx
我将我的ContactDao定义如下:
public interface ContactDao extends JpaRepository<Contact, Long> {
/**
* Finds all contacts that the given user has entered where the contact's full name matches {@code name}.
* @param userId The current user's LDAP id.
* @param name The name to search f
有人能帮我找出我的错误吗?
JPA函数:
@Query("select d from deliverypartnerrecord d where d.status = :d_status and d.id = :d_id")
public Deliverypartnerrecord findDeliveryPartnerRecordById(@Param("d_id") int id, @Param("d_status") String status);
错误:
Error creating bean with name 'deliver
我有两个实体雇员和部门如下:
@Entity
@Table(name="employee")
public class EmployeeDAO implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(unique=true, nullable=false)
private Long id;
@Column(nam
我用这个tutorial温习了一下JPARepository,得到了以下关于spring的依赖问题: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userPersistence' defined in persistence.UserPersistence defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaReposit
在Spring中使用@Query时出现不满意的依赖错误
在我的存储库中,我添加了查询来连接表,但是在运行时得到了错误。
ERROR:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'empcontroller': Unsatisfied dependency expressed through field 'emprepo'; nested exception is org.springframework.beans.
我想在spring存储库@Query中使用JPA2.0Type表达式,但是它给了我一个验证错误Validation failed for query for method public abstract java.util.List my.org.FooRepository.findAllByRoomCode()!。
以下是我的实体定义:
继承:
@Entity(name = "Location")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class LocationEnt
嗨,我已经设置了一个Spring (4)+Postgresql+JPA应用程序,我遇到了以下情况:我想为我的“用户”存储库设置自定义查询,因此将这些行添加到现有(空)UserRepository中:
public interface AccountRepository extends JpaRepository<User,Long> {
@Query("select u from User u where u.Email = ?1")
User findByEmail(String emailAddress);
}
对于空存储库,服务器一切正常,上
我肯定遗漏了一些东西,但是很难弄清楚什么是hibernate的JPA验证失败了。
当hibernate中的JPA注释验证失败时,您将得到如下异常:
javax.validation.ConstraintViolationException: validation failed for classes [com.evocatus.domain.Sauce] during persist time for groups [javax.validation.groups.Default, ]
这是非常没有帮助的。
您可以通过log4j打开实际验证失败的日志记录:
<logger name=
我有一个给我带来麻烦的@Query。我想要获取所有具有给定父项的网页,即使给定的父项为空。
可以设置父级,但也可以不设置父级。
我一直在尝试这样做:
@Query("SELECT w FROM Webpage w WHERE w.parent = :parent OR (parent IS NULL AND :parent.id < '1')) ORDER BY w.listOrder")
public Page<Webpage> findByParent(@Param("parent") Webpage parent, Pag
我正尝试在Spring Data Jpa Repository中使用FOR UPDATE with SELECT。
下面的查询在数据库控制台上运行时不会给出错误。但是在Spring Data中,JPA抛出了一个异常,它不能识别以下查询中的token。
在第一行代码中故意使用大括号而不是大于和小于符号,因为它在尝试发布问题时将数据隐藏在这些标记中
public interface XRepository extends JpaRepository(X, String) {
@Query(value = "SELECT UPDATE t FROM X t WHERE t.a = ?1 AN
在Spring Data JPA中,尝试使用接口投影技术: interface DocInfoShort {
var docTypeId: Int
} 还有我的刀: public interface DocRepository extends JpaRepository<Doc, Long> {
@Query("select sum(cast(doc.isSent AS int)) as docTypeId" +
" from Doc doc group by docTypeId", native
存储库类
@Repository
public interface AllFileRepository extends JpaRepository<AllFile, Long> {
@Query("SELECT a From AllFile a where a.guid = :guid")
AllFile findByGuid(@Param("guid") String guid);
}
服务等级
@Service
@Data
public class PipelineService implements Serializable {
我正在寻找一种使用Spring Data JPA动态构建查询的解决方案。我有一个GameController,它有一个RESTful服务端点/games,它接受4个可选参数:流派、平台、年份、标题。API可能不会被传递其中任何一个,全部4个,以及它们之间的每一个组合。如果有任何参数没有被传递,它缺省为null。我需要存储库中的一个方法来构建适当的查询,并且理想情况下仍然允许Spring Data JPA分页,尽管我不确定这是否可能。
我找到了这篇文章,但这似乎不是我需要的,除非我误解了。
我知道JPA有一个查询条件API,但我真的不知道如何实现它。
我意识到我可以为每个可能的场景创建一个方法,
我正在尝试使用JPA和JPQL来查询我的实体,并从表中返回一列的总和(总天数)。我认为我已经正确地设置了它,但我得到了这个错误:
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'myRepository':
Invocation of init method failed; nested exception is
java.lang.IllegalArgumentException: Validation failed for q
我正尝试在我的JPA代码库中为一个简单的项目执行自定义查询,我使用spring和angular做了一个简单的项目,我得到了一些我找不到的错误。所有我需要的是一个基于userName的登录系统的ID。 我的存储库 package systemphones.backend.repository;
imports...
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
@Query("SELECT ID FROM USER WHERE USER_NAME
我想用来自mysql数据库的数据使用jfree图表创建一个片段图,但是l似乎得到了错误。这是我的代码。 我有一个LocationRepository,其中l实现了我的sql查询。 public interface LocationRepository extends JpaRepository<Location, Integer> {
//hibernate query language (jpql)
@Query("select type,count(type) from location group by type")
我得到了一个错误whenI lauch
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userService': Unsatisfied dependency expressed through field 'userRepository'; nested
我已经修改了一个现有的RESTful/JDBC应用程序,我必须使用Spring 4中的新特性。特别是JpaRepository。它将:
1)检索指定日期的事务列表。这个很好用
2)按类型检索指定日期的事务计数。这不像预期的那样有效。查询的设置类似,但实际返回类型非常不同。我对每个查询都有POJO。
我的事务JPA存储库如下所示:
public interface MyTransactionsRepository extends JpaRepository<MyTransactions, Long>
//My query works like a charm.
@Query( v