小编Gau*_*put的帖子

如何使用hibernate生成自定义标识,同时它必须是表的主键

这是我的pojo课程

@Entity

public class Department {


@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)

@Column(name="Department_Id")

private Integer deptId;


@Column(name="Department_Name",unique=true,nullable=false)
private String deptName;


@Column(name="Department_Description")
@NotNull
private String deptDesc;
   //geters and setters
Run Code Online (Sandbox Code Playgroud)

我想要的是department_id必须是此Department表的主键,此键的条目必须为DEP0001,DEP0002,DEP0003

hibernate jpa

20
推荐指数
2
解决办法
4万
查看次数

如何使用shell脚本连接到postgresql数据库

我想编写一个shell脚本来运行这些命令.我通常使用如下命令从终端连接

    //first go to the directory 
     cd /opt/novell/sentinel/3rdparty/postgresql/bin/
    // then type following
     export LD_LIBRARY_PATH=/opt/novell/sentinel/3rdparty/postgresql/lib/
    // then fire following command 
     ./psql --host 127.0.0.1 --port 5432 --dbname=SIEM --username=dbauser
     Password for user dbauser: ****
Run Code Online (Sandbox Code Playgroud)

shell psql

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

如何在postgres中使用shell脚本触发VACUUM命令

这是我的shell脚本

    #!/bin/bash
    psql --host=127.0.0.1 --port=5432 --dbname=SIEM --username=dbauser
    vacuumdb --analyze --verbose --table 'vuln' SIEM
Run Code Online (Sandbox Code Playgroud)

但它没有正常工作,并给出错误:

   linux-lxh4:/home/gaurav # ./script.sh 
   psql (9.2.5)
   Type "help" for help.

   SIEM=# \q
   vacuumdb: could not connect to database root: FATAL:  Peer authentication failed for user "root"
Run Code Online (Sandbox Code Playgroud)

Edit1:我使用了这段代码:

   psql --host=127.0.0.1 --port=5432 --dbname=SIEM --username=dbauser
   VACUUM FULL VERBOSE vuln 
Run Code Online (Sandbox Code Playgroud)

这是错误:

   ./script.sh: line 4: VACUUM: command not found
Run Code Online (Sandbox Code Playgroud)

shell psql

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

标签 统计

psql ×2

shell ×2

hibernate ×1

jpa ×1