在找工作的同时,我参加了一些在金融领域工作的公司的求职面试.每家公司都使用Spring Framework作为开发的主要框架.几乎在所有地方我都被告知'我们需要经过验证和稳定的技术,这就是我们使用Spring的原因.'
我想知道,正如我无法理解的那样,为什么Spring比Java EE更受欢迎和"更安全"(例如,Spring MVC比JSF使用更多,而两者都提供了几乎相同的功能)?
原始Java EE功能如何可能比第三个库更不稳定?
这是我的代码部分:
Query q = em.createNativeQuery("insert into table_name (value_one, value_two, value_three) values (?,?,?)");
q.setParameter(1, value1);
q.setParameter(2, value2);
q.setParameter(3, value3);
q.executeUpdate();
Run Code Online (Sandbox Code Playgroud)
value3
有时可以为null(Date类对象).如果为null,则抛出以下异常:
Caused by: org.postgresql.util.PSQLException: ERROR: column "value_three" is of type timestamp without time zone but expression is of type bytea
Hint: You will need to rewrite or cast the expression.
Position: 88
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:334)
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:189)
... 11 more
Run Code Online (Sandbox Code Playgroud)
如何使这段代码工作并将空值保存到数据库中?
我正在使用postgreSQL 9.1,我想使用这个技巧从我的表中删除重复项:https: //stackoverflow.com/a/3822833/2239537
所以,我的查询看起来像这样:
WITH cte
AS (SELECT ROW_NUMBER()
OVER (PARTITION BY code, card_id, parent_id
ORDER BY id DESC) RN
FROM card)
DELETE FROM cte
WHERE RN > 1
Run Code Online (Sandbox Code Playgroud)
但它告诉我
ERROR: relation "cte" does not exist
SQL state: 42P01
Character: 157
Run Code Online (Sandbox Code Playgroud)
但是这个说法很好:
WITH cte
AS (SELECT ROW_NUMBER()
OVER (PARTITION BY code, card_id, parent_id
ORDER BY id DESC) RN
FROM merchantcard)
SELECT * FROM cte
WHERE RN > 1
Run Code Online (Sandbox Code Playgroud)
任何想法如何让它工作?谢谢!
Need some Guru advice.
Our system checks if the current client's total Debt amount
exceeds allowed Credit amount
and if true, adds new Debt
entry
if (additionalDebtAllowed(clientId, amount)) {
deptRepository.saveAndFlush(new Debt(clientId, amount));
}
Run Code Online (Sandbox Code Playgroud)
In additionalDebtAllowed()
we get all active debt rows by client id and compare with the credit limit, that we get from another system.
问题在于REST调用可能是并发的,我们可以在以下情况下运行:
最简单的方法是在读取和保留数据之前,尝试通过客户端ID锁定数据库中的某些行。如果成功-继续并解锁。如果失败-重试直到成功。但我认为可能会有更漂亮的方法。
考虑了SERIALIZABLE Isolation Level,但是它将锁定整个表,而我仅需要每个客户端进行同步。
我需要用逗号或点或反斜杠分割String:
Pattern stringPattern = Pattern.compile("\\s+|,|\\\\|");
Splitter.on(stringPattern).omitEmptyStrings().split(description));
Run Code Online (Sandbox Code Playgroud)
但这种模式不起作用,有什么不对?
java ×3
concurrency ×1
guava ×1
java-ee ×1
jpa ×1
postgresql ×1
split ×1
splitter ×1
spring ×1
spring-boot ×1
spring-data ×1
spring-mvc ×1
sql ×1
transactions ×1