小编Dau*_*ali的帖子

从Postgres中的jsonb通过未知键获取元素

我有以下数据结构:

{
    "proccess1": {
        "error": "error1 description",
        "nextRetryAt": "2018-02-22T07:39:00.325Z",
        "attemptsMade": 148,
        "firstFailedAt": "2018-02-16T06:40:41.327Z"
    },
    "proccess2": {
        "error": "error2 description",
        "nextRetryAt": "2019-03-16T06:41:01.566Z",
        "attemptsMade": 77,
        "firstFailedAt": "2016-03-15T04:35:12.248Z"
    }
}
Run Code Online (Sandbox Code Playgroud)

我的问题是如何构建查询

select * 
from data 
where data->[0]->>'nextRetryAt' = 'my passed value'
Run Code Online (Sandbox Code Playgroud)

我不知道键proccess1proccess2. 他们可能有任何价值。

postgresql json jsonb

5
推荐指数
1
解决办法
1046
查看次数

在servlet上下文侦听器中获取servlet init params

 <listener>
    <listener-class>config</listener-class>
</listener> 
  <servlet>
<servlet-name>ProcessReg</servlet-name>
<servlet-class>ProcessReg</servlet-class>
<init-param>
    <param-name>text</param-name>
    <param-value>HelloWorld1</param-value>
</init-param>
Run Code Online (Sandbox Code Playgroud)

public class config implements ServletContextListener {



@Override
public void contextInitialized(ServletContextEvent event) {
    ServletContext servletContext = event.getServletContext();
    String text1 = servletContext.getInitParameter("text");
Run Code Online (Sandbox Code Playgroud)

在方法中 contextInitialized(ServletContextEvent event),如果有两个servlet,例如,让我们说第二个servlet的名称是,Servlet2并且它可以说已经init - param调用text了值HelloWorld2.

怎么listener 知道服用ProcessRegservlet?

如何paramServlet2

servlets init-parameters servletcontextlistener

4
推荐指数
1
解决办法
3227
查看次数

DAO可以用于多个表吗?

我正在开发javaSE中的小应用程序,只是为了让我的技能更好.所以我有业务服务(BS进一步),其中一些方法就像registerUser(用户用户),addAmount(长accountId).BS使用dao.假设从WS或其他接口元素调用BS.我有以下DAO:

public interface UserDao {

    User getUserByUsername(String username);

    void saveUser(User user);
}

public interface AccountDao {

    void saveAccount(Account account);

    Account getAccountByUserId(Long userId);
}
Run Code Online (Sandbox Code Playgroud)

我的BS看起来像

public class FastAccountServiceImpl implements FastAccountService{

private UserDao userDao;
private AccountDao accountDao;

public void registerUser(User user, Account account) throws Exception {
    if (user.getUsername() == null || user.getUsername().isEmpty()) {
        throw new Exception("all params are mandatory");
    }
    if (userDao.getUserByUsername(user.getUsername()) != null) {
        throw new Exception("This user exists");
    }
    userDao.saveUser(user);
    accountDao.saveAccount(account);
}

public void withdrawAmount(Double amount, Long userId) throws Exception …
Run Code Online (Sandbox Code Playgroud)

java spring dao

1
推荐指数
1
解决办法
1802
查看次数