getModifiers()的Java Doc 如下:
int getModifiers()
以整数形式返回此Member表示的成员或构造函数的Java语言修饰符.应使用Modifier类来解码整数中的修饰符.
和Java Docs还提供了不同修饰符及其对应的int值的列表:
public static final int ABSTRACT 1024
public static final int FINAL 16
public static final int INTERFACE 512
public static final int NATIVE 256
public static final int PRIVATE 2
public static final int PROTECTED 4
public static final int PUBLIC 1
public static final int STATIC 8
public static final int STRICT 2048
public static final int SYNCHRONIZED 32
public static final int TRANSIENT 128
public …
我正在使用Eclipse Kepler来开发我的Java项目.我创建了一个vo并在vo中添加了一些属性.为这些属性生成getter和setter方法,我右键单击一个属性然后转到"Source"
然后单击"Generates Getters and Setters"
.它向我展示了属性的可用getter/setter方法.下面是屏幕截图
正如你可以在上面的截图中看到,Eclipse是我提供getter和setter方法的属性SID是
public String getsId() {
return sId;
}
public void setsId(String sId) {
this.sId = sId;
}
Run Code Online (Sandbox Code Playgroud)
get和set之后的第一个字母是小写字母(get s Id和set s Id).
对于属性,Eclipse正在创建所需的getter和setter方法.
我的观察是,任何财产,其第二个字母是大写(对于示例- SID:第一个字母(小号)是在小型和第二信(我)是资本)日食发生在以下格式的getter和setter
get+property name
set+property name
Run Code Online (Sandbox Code Playgroud)
但如果属性的第二个字母是小写字母 eclipse正在以下面的格式生成getter和setter
get+1st letter in capital letter+ rest of the property name
set+1st letter in capital letter+ rest of the property name
Run Code Online (Sandbox Code Playgroud)
即使如果该属性的第一个字母是大写字母,eclipse也会以下面的格式生成getter和setter
get+1st letter (which is already in …
Run Code Online (Sandbox Code Playgroud) 据我所知
最后一个类只是一个无法扩展的类.
除了在同一个类中的表单之外,不能实例化具有私有构造函数的类.这使得从另一个类扩展它无用.但这并不意味着它根本不能被分类,在内部类中我们可以扩展并调用私有构造函数.
所以我的理解是,如果我们用单个无参数私有构造函数创建一个类,那么将它们声明为final是没有意义的.那么为什么Java中的System类声明为final类,尽管它有单个无参数的私有构造函数?
我听说上课最后有一些表现.这是正确的,这是将System类声明为final的唯一原因吗?请澄清为什么Java像这样实现了System类.
我maven-3.2.5
在Linux Mint Throgh CLi上安装了最新的安装细节如下:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
export M2_HOME=/home/mani/apache-maven-3.2.5/bin/
Run Code Online (Sandbox Code Playgroud)
在命令中它显示如下:
mani@manithullimilli ~/apache-maven-3.2.5/bin $ ./mvn version
Run Code Online (Sandbox Code Playgroud)
错误:无法找到或加载主类org.codehaus.plexus.classworlds.launcher.Launcher mani @manithullimilli~/apache-maven-3.2.5/bin $
我也设置了路径
我有一个旧项目,在该项目中我使用了Java API中的Date,并且要将其更改为新的Java 8 Date API LocalDateTime
。我读到5之前的Hibernate版本不支持新的Java 8 Date API,因此我决定从Hibernate 4.3.6迁移到5。在旧项目版本中,一切正常,但是当我更改Hibernate版本时,出现错误我尝试启动我的应用程序:
wrz 21, 2015 7:14:23 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.8.0_31\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:/Program Files/Java/jre1.8.0_31/bin/server;C:/Program Files/Java/jre1.8.0_31/bin;C:/Program Files/Java/jre1.8.0_31/lib/amd64;D:\oraclexe\app\oracle\product\11.2.0\server\bin;;C:\ProgramData\Oracle\Java\javapath;D:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;D:\Program Files\eclipse;;.
wrz 21, 2015 7:14:23 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: …
Run Code Online (Sandbox Code Playgroud) 我只是在使用Spring Hibernate事务管理器尝试使用getCurrentSession时升级到hibernate 5并面临以下错误
org.springframework.orm.hibernate5.HibernateTransactionManager
Run Code Online (Sandbox Code Playgroud)
这是错误的完整堆栈跟踪
java.lang.IllegalStateException: Already value [org.springframework.orm.hibernate5.SessionHolder@c05f59] for key [org.hibernate.internal.SessionFactoryImpl@f0db1] bound to thread [http-bio-8080-exec-3]
at org.springframework.transaction.support.TransactionSynchronizationManager.bindResource(TransactionSynchronizationManager.java:190) ~[spring-tx-4.2.2.RELEASE.jar:4.2.2.RELEASE]
at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:129) ~[spring-orm-4.2.2.RELEASE.jar:4.2.2.RELEASE]
at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:692) ~[hibernate-core-5.0.2.Final.jar:5.0.2.Final]
at com.pos.core.repository.persistance.framework.impl.BaseHibernateRepository.getCurrentSession(BaseHibernateRepository.java:42) ~[Core-2.5.2-SNAPSHOT.jar:?]
at com.pos.infrastructure.security.repository.impl.LoginSessionRepositoryImpl.getLoginSessionInfo(LoginSessionRepositoryImpl.java:83) ~[Infrastructure-2.5.2-SNAPSHOT.jar:?]
at com.pos.infrastructure.authentication.services.impl.AuthenticationServiceImpl.checkLoginSessionInfo(AuthenticationServiceImpl.java:1087) ~[Infrastructure-2.5.2-SNAPSHOT.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_60]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_60]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_60]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) ~[spring-aop-4.2.2.RELEASE.jar:4.2.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.2.2.RELEASE.jar:4.2.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.2.2.RELEASE.jar:4.2.2.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.2.2.RELEASE.jar:4.2.2.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) [spring-tx-4.2.2.RELEASE.jar:4.2.2.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) [spring-tx-4.2.2.RELEASE.jar:4.2.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.2.2.RELEASE.jar:4.2.2.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) [spring-aop-4.2.2.RELEASE.jar:4.2.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.2.2.RELEASE.jar:4.2.2.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) [spring-aop-4.2.2.RELEASE.jar:4.2.2.RELEASE]
at com.sun.proxy.$Proxy168.checkLoginSessionInfo(Unknown Source) …
Run Code Online (Sandbox Code Playgroud) 我正在使用 Hibernate 5 和 Spring 3.2.4。我正在设计一个用户实体,我想在其中包含对创建实体的用户的引用 - 所以是自我引用。自引用本身并没有太大问题,但我想将该字段指定为非空。这可能吗?如果该字段不为空,因为引用的实体不存在,如何在数据库中创建第一个条目?
前任:
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long User.id;
@NotNull
private String username;
private String password;
@NotNull
private User user;
// getters and setters omitted for brevity
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试:
User u = new User();
u.setUsername("username");
u.setCreatedBy(u);
Run Code Online (Sandbox Code Playgroud)
并尝试坚持u
,我收到以下错误消息:
Caused by: org.hibernate.TransientPropertyValueException: Not-null property references a transient value - transient instance must be saved before current operation: com.domain.User.createdBy -> com.domain.User
Run Code Online (Sandbox Code Playgroud)
我知道 Hibernate 抱怨它无法引用瞬态实例(即:)u
,但 …
我正在从hibernate 4.2.17迁移到5.0.7到目前为止工作正常,但似乎该方法isActive
已被弃用.我不能再使用它了.
这是我的代码:
public void starteTransaktion() {
try {
getMySession();
if(!hibernateSession.getTransaction().isActive()) {
hibernateSession.beginTransaction();
}
} catch (HibernateException e) {
}
}
Run Code Online (Sandbox Code Playgroud)
我替换了所有其他方法,但我找不到替代方法......
错误消息:isActive()
对于类型Transaction,该方法未定义
当我将Hibernate 5添加到我的网站时,我无法在Glassfish 4.1.1中使用它.我总是得到一个错误
java.lang.NoSuchMethodError:org.jboss.logging.Logger.debugf(Ljava/lang/String; I)V
我试图替换Glassfish模块文件夹中的jboss-logging库,就像我在回答类似问题时读到的那样,但它没有改变任何东西.我也尝试使用Hibernate 4,但这给了另一个错误.