我只是写了一个小方法来计算手机短信的页数.我没有选择使用Math.ceil
,老实说它似乎非常难看.
这是我的代码:
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String message = "today we stumbled upon a huge performance leak while optimizing a raycasting algorithm. Much to our surprise, the Math.floor() method took almost half of the calculation time: 3 floor operations took the same amount of time as one trilinear interpolation. Since we could not belive that the floor-method could produce such a enourmous overhead, …
Run Code Online (Sandbox Code Playgroud) 我已经打了一个拦截器将修复到现有project.the主要问题是,我一定会喜欢使用@Prepersist
,并@PreUpdate
在POJO
照顾LastModified
使用Hibernate与会话实现JPA的领域(INSERT和UPDATE).
原因?:这个更改是必需的,因为需要使用liquibase 1.9.5
并且我知道(因为我之前已经面对过)liquibase将时间戳转换为使用默认current_timestamp的日期时间,这对于mysql数据库来说太糟糕了.
所以我需要一种方法来在代码中而不是在数据库中设置这个集合所以我可以安全地将时间戳字段更改为datetime.then liquibase很高兴,我很高兴.
现在似乎那些解释器没有被执行,很少有搜索我发现它适合使用entityManager
.目前是不可能的.所以我想知道是否有一个简单的方法解决我的问题,这意味着有@Prepersist
或@PreUpdate
或甚至其他解决方法来设置lastModified
仍然使用会话的字段
我是这个论坛的新手,但我偶尔也是一个vbox用户.我有Windows 7主机和ubuntu 9.10客户端安装vboxadditions工作正常,共享文件夹和一切完美.现在进行一些模拟,我需要使用x-window安装ubuntu服务器10.04.我做了什么,到目前为止很好.
现在我现在遇到的问题是,对于服务器我似乎无法挂载共享文件夹.按照相同的过程:
-install DKMS
-update
-upgrade
-mount的vboxadditions异在主机虚拟驱动器和具有它安装在客人以及
-install vboxadditions(须藤SH ./VBoxLinuxAdditions-x86.run)
-restart客户OS
-创建ubuntu_share文件夹下/媒体/ ubuntu_share
任何时候我试图使用此命令在我的驱动器D(D:/ Ubuntu_Share)上安装文件夹ubuntu_share:
mount -t vboxsf ubuntu_share /media/ubuntu_share
Run Code Online (Sandbox Code Playgroud)
我总是得到:
/sbin/mount.vboxsf mouning failed with error: no such device
locate mount.vboxsf output this:
/opt/VBoxGuestAdditions-3.2.6/lib/VBoxGuestAdditions/mount.vboxsf
/sbin/mount.vboxsf
Run Code Online (Sandbox Code Playgroud)
ubuntu服务器10.04有什么问题吗?或者我只是在某个地方错过了标记?感谢您阅读本文并帮助我.
感谢你们,我对hibernate的了解已经得到了很大的改善.现在我在这里打了一个关于current_timestamp的块.这是我的代码
@Column(name="DATE_CREATED", insertable=false, updatable=false, columnDefinition="timestamp default current_timestamp")
@org.hibernate.annotations.Generated(value=GenerationTime.INSERT)
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date dateCreated;
@Column(name="LAST_MODIFIED", insertable=false, updatable=false, columnDefinition="datetime")
@org.hibernate.annotations.Generated(value=GenerationTime.ALWAYS)
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date lastModified;
Run Code Online (Sandbox Code Playgroud)
我希望date_created获取current_timestamp,我希望lastmodified为每次更新插入时间.显然我不能在同一个表上有2个current_timestamp字段.还有其他方法可以实现吗?谢谢阅读
我一直在努力在我的环境中获得ehcache 2.1.0.任何时候我认为我做对了,它只是没有下载它.这是我设置存储库的地方:
<repository>
<!--<url>https://oss.sonatype.org/content/repositories/releases/</url>-->
<url>http://oss.sonatype.org/content/repositories/sourceforge-releases</url>
<id>sonatype-mirror</id>
<layout>default</layout>
<name>Repository for library including ehcache recent ones</name>
</repository>
Run Code Online (Sandbox Code Playgroud)
我以这种方式添加依赖项:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.1.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
有什么东西我做错了或不合适吗?
我即将发布一个项目,但似乎JAVA_HOME不一致.也许它被其他地方覆盖了?我使用的是ubuntu 14.04,我有openjdk-7,java-7-oracle,java-8-oracle.使用默认java设置update-java-alternatives
java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
Run Code Online (Sandbox Code Playgroud)
mvn -version给出以下输出
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T17:37:52+00:00)
Maven home: /usr/share/maven3
Java version: 1.8.0_25, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-39-generic", arch: "amd64", family: "unix"
Run Code Online (Sandbox Code Playgroud)
但是在做mvn发布时:准备,下面是我看到的:
[INFO] Not generating release POMs
[INFO] Executing goals 'clean verify'...
[WARNING] Maven will be executed in interactive mode, but no input stream …
Run Code Online (Sandbox Code Playgroud) 我一直在尝试这个正式给我做恶梦的查询.该系统是用户和联系人管理.所以我有UserAccount
,Contact
而且Phone
.
UserAccount
与Contact
手机上的单向一对多关系以及手机上的单向关系全部映射为Set
:
//UserAccount mapping
@OneToMany(targetEntity=PhoneImpl.class, cascade= {CascadeType.ALL})
@org.hibernate.annotations.Cascade(value=org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private Set<Phone> phones = new HashSet<Phone>();
@OneToMany(targetEntity=ContactImpl.class, cascade={CascadeType.ALL}, mappedBy="userAccount")
@org.hibernate.annotations.Cascade(value=org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
private Set<Contact> contacts = new HashSet<Contact>();
Run Code Online (Sandbox Code Playgroud)
现在联系人有一对多的单向电话
@OneToMany(targetEntity=PhoneImpl.class, cascade={CascadeType.ALL})
private Set<Phone> phones = new HashSet<Phone>();
Run Code Online (Sandbox Code Playgroud)
我正在编写一种方法,通过电子邮件唯一字段检查特定用户的相同联系人是否存在相同的号码.
我知道我可以覆盖equals
并且hashcode
为此而且因为在集合映射的实体中的电话我现在不知道如何做到这一点.所以我想提供一种方法,在联系页面上的每个条目之前为我检查该唯一性
public boolean checkForExistingPhone(String userEmail, String formatedNumber) {
List<Contact> result = null;
Session sess = getDBSession().getSession();
String query = "select Contact ,cphones.formatedNumber from Contact c inner join Contact.phones cphones where c.UserAccount.email …
Run Code Online (Sandbox Code Playgroud) 可能重复:
jqGrid重新定位删除确认框
我已经开始使用jqGrid几天了,而且一切都很酷.这么好.与我NavGrid
无关的是,当你在没有选择行的情况下点击编辑按钮时,它会显示一个居中的模态弹出窗口,通知没有选择任何行.但是当你点击添加或编辑(带有选定的行)时,它会在网格的左侧显示一个模态.没有居中.
我想找到一种方法来集中它.
怎么做的?或者它无法开箱即用?
谢谢你读这个
我选择了一个新创建的maven webapp项目,并想用它做最简单的mvc应用程序.我的环境看起来像这样:
<artifactId>spring-core</artifactId>
<artifactId>spring-test</artifactId>
<artifactId>spring-beans</artifactId>
<artifactId>spring-context</artifactId>
<artifactId>spring-aop</artifactId>
<artifactId>spring-context-support</artifactId>
<artifactId>spring-tx</artifactId>
<artifactId>spring-orm</artifactId>
<artifactId>spring-web</artifactId>
<artifactId>spring-webmvc</artifactId>
<artifactId>spring-asm</artifactId>
<artifactId>log4j</artifactId>
<artifactId>hibernate-core</artifactId>
<artifactId>hibernate-cglib-repack</artifactId>
<artifactId>hsqldb</artifactId>
<!-- particular arears-->
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- -->
<spring.version>3.0.5.RELEASE</spring.version>
<hibernate.version>3.6.1.Final</hibernate.version>
<hibernate-cglig-repack.version>2.1_3</hibernate-cglig-repack.version>
<log4j.version>1.2.14</log4j.version>
<javax-servlet-api.version>2.5</javax-servlet-api.version>
<hsqldb.version>1.8.0.10</hsqldb.version>
<mysql-connector.version>5.1.6</mysql-connector.version>
<slf4j-log4j12.version>1.5.2</slf4j-log4j12.version>
<slf4j-api.version>1.5.8</slf4j-api.version>
<javaassist.version>3.7.ga</javaassist.version>
<taglibs.version>1.1.2</taglibs.version>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-beta-1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
<finalName>admin-webapp</finalName>
</build>
<profiles>
<profile>
<id>endorsed</id>
<activation>
<property>
<name>sun.boot.class.path</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<!-- …
Run Code Online (Sandbox Code Playgroud) 我正在利用liquibase库,我想模仿现有的数据库.所以从命令行我设法生成更改日志,我想知道是否有可能为表中的数据生成插入语句?
谢谢你读这个.