我需要检查一个字符串,该字符串应该只包含ABCDEFG字符,任何顺序且只有7个字符.请告诉我使用正则表达式的正确方法.
正如我正在使用的那样
String abs = "ABPID";
if(!Pattern.matches("[[ABCDEFG]", abs))
System.out.println("Error");
Run Code Online (Sandbox Code Playgroud)
我正在使用以下代码,当我使用String abcdefg时,它可以工作,但对于其他情况,它会失败.请帮帮我.
我说了10个测试用例,我想从java类运行它们,我只能在运行时获取Junit的类名.是否可以这样做.
请帮我.
我正在使用hibernate作为ORM工具,并在从表中加载数据时,我收到以下错误.
org.hibernate.HibernateException: CGLIB Enhancement failed: com.hotel.entity.HotelUser
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:96)
at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.getProxy(CGLIBProxyFactory.java:49)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:379)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3455)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:257)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:191)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:795)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:788)
at com.hotel.domain.UserLoginService.checkUserCredentials(UserLoginService.java:17)
at com.hotel.app.UserLoginManager.checkUserCredentials(UserLoginManager.java:12)
at com.hotel.app.UserLoginManager.main(UserLoginManager.java:23)
Caused by: java.lang.InstantiationException: com.hotel.entity.HotelUser$$EnhancerByCGLIB$$fa712a57
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyInstance(CGLIBLazyInitializer.java:107)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:93)
... 12 more
Run Code Online (Sandbox Code Playgroud)
请让我知道,我想念的是什么......
下面是我的班级
public class HotelUser implements Serializable {
private static final long serialVersionUID = 1L;
private String userId;
private String password;
private String userName;
private HotelUser() {
}
/**
* @param …Run Code Online (Sandbox Code Playgroud) 我面临一个问题。我有一个疑问
Select * from tabA
where (a) in (a,b,c)
OR b in (a,b,c)
Run Code Online (Sandbox Code Playgroud)
我想由于此查询而面临性能问题,因为我需要删除 or 条件,所以我尝试使用以下查询:
Select * from tabA
where (a,b) in (a,b,c)
Run Code Online (Sandbox Code Playgroud)
但这个查询似乎不起作用,请帮忙。我不想使用“或”条件。
我使用以下代码创建一个唯一的ID,它是8个字符(包括数字和字母数字字符).
try {
List<String> uuidList = new ArrayList<String>();
int counter = 1;
File file = new File("D://temp//temp1.txt");
file.createNewFile();
Writer writer = new FileWriter(file);
BufferedWriter wr = new BufferedWriter(writer);
while(true) {
int length = bitsArray.length;
Random r = new Random();
StringBuffer uuid = new StringBuffer();
for(int i= 0; i < 8; i++) {
int nextRandomId = r.nextInt(length);
uuid.append(bitsArray[nextRandomId]);
}
String uuidString = uuid.toString();
wr.write(uuidString);
wr.newLine();
if(counter != 1 && uuidList.contains(uuidString)) {
Thread.sleep(1000);
System.err.println(counter);
break;
}
//061e735145fc
System.err.println(uuidString);
uuidList.add(uuidString);
counter++;
}
} …Run Code Online (Sandbox Code Playgroud) Java null != something和something != nullJava 之间是否存在差异?如果存在差异,那么我应该使用哪一个?为什么?
java ×5
hibernate ×1
junit4 ×1
null-check ×1
oracle ×1
performance ×1
plsql ×1
regex ×1
uuid ×1