Is there a way to "magically" persist a column which is not represented as a property in an entity? Concretely I want to add audit info to an entity without having the audit info on the entity. The audit values are not stored in the entity, but are retrieved from the environment at the time of persisting the entity. This happens in a AuditInfoUserType. The nullSafeSet gets the info from the SecurityContext, instead of reading from the entity.
In the hibernate mapping, however, the audit info properties have to be defined.
Is there a way in hibernate to define columns without properties?
Hi.... This is a exremely stupid question but i need help with this.... I'm trying to make a small program that i made robust and needed some help with tht....
int num1;
int num2 = 0;
System.out.print("Enter number 1: ");
num1 = kb.nextInt();
while(num2<num1)
{
System.out.print("Enter number 2: ");
num2 = kb.nextInt();
}
Number 2 has to be greater than number 1
Also i want the program to automatically check and ignore if the user enters a char instead of an int... Cause right now when a user enters lets say "r" instead of a number the program just exists....
Is there any framework that fills up rtf document with data?
The idea is to make business people/testers change the document in MsWord and than generate reports from that.
The problem is with tables, Id need to create some special DSL for handling tables and showing hidding text/page parts. Id rather not do that and use some existing solution.
I tried to search for something, but I only found frameworks that can produce rtf output from xml input and i want to use rtf as input and output.
hi friend,
I have created the project using the JDK 1.4. Now I want to use JDK 1.6 version in my project.
for this what steps are required.Means I want to know the what changes is require in code to get a JDK 1.6 feature.Basically I am talking about the features that is added in JDK 1.6. If any one list out that changes it is very helpful.
Thanks in advance..............................
I would like to implement pagination in my Servlet/EJB/JPA-Hibernate project, but I can't figure out how only one page from the query and know the number of pages I must display
I use
setFirstResult(int first) ;
setMaxResults(int max) ;
and that's working alright, but how can I know how many pages I will have in total?
(Hibernate is my JPA provider, but I would prefer using only JPA if possible)
UPDATE: COUNT() seems to be the better/easiest solution;
but what can be the cost of SELECT COUNT(*) FROM ... in comparison with
executeQuery("SELECT * FROM ...).getListResult().size() ?
I need to multiple all the values in an array by 3000 which in turn would create a new array that I will use to subtract from another array. I've tried to create a separate method that would do that for me but all I got back in the multiplied array was a bunch of numbers and symbols strangely?
here is the code that I wrote
public static void main(String[] args)
{
int numberOfTaxpayers = Integer.parseInt(JOptionPane.showInputDialog("Enter how many users you would like to calculate taxes for: ");
int[] usernumChild = new int[numberOfTaxPayers];
for (int i = 0; i < usernumChild.length; i++)
{
usernumChild[i] = Integer.parseInt(JOptionPane.showInputDialog("Enter number of children for user "+ (i+1) +": "));
}//this for loop finds out the number of children per user so we can later multiply each input by 3000 to create an array that determine dependency exemption for each user
int[] depndExemp = multiply(usernumChild, 3000);//this was the calling of the multiply method... somewhere here is the error!!
}//end main method
public static int[] multiply(int[] children, int number)
{
int array[] = new int[children.length];
for( int i = 0; i < children.length; i++)
{
children[i] = children[i] * number;
}//end for
return array;
}//this is the method that I was shown in a previous post on how to create return an array in this the dependency exemption array but when I tested this by printing out the dependency array all I received were a jumble of wrong numbers.
My code runs inside a jar file, say foo.jar, and I need to know, in the code, in which folder the running foo.jar is.
So, if foo.jar is in C:\FOO\, I want to get that path no matter what my current working directory is.
Hi All,
I am having a designation table with d_name as primary key which i am using in user table as foreign key reference .I am using hbm for mapping in designation hbm i have id defined as d_name mapped to database column .I am getting a error saying
"integrity constraint violation(user_designation_fk) parent key not found. "
Where am i going wrong /this error is coming while i am tring to add a user selecting a designation reading from designation table.
My issue is that i have an annotation in Struts2 action class like
private String[] origfilenofrom;
@FieldExpressionValidator(fieldName="origfilenofrom",key="",message="File Length should be 12 for old file format and 15 for new file format",expression="checkorigFileFormat(origfilenofrom)")
now my mehtod is
public boolean checkorigFileFormat(String[] files )
{
for(int counter=0;counter<files.length;counter++)
{
int n=files[counter].length();
if(!(n==12 || n==15))
{
return false;
}
}
return true;
}
So for any string in that string [], which is returning false the value is bei false.
No matter 3 strings in that string [] are true if one is false then the annotaion message is displayed for all.
I want the message not to display where the string is true.
Help please
So I change the -vm argument for eclipse.exe using the eclipse.ini settings file, and now there's an command prompt console (even if I remove the -vm value).
Does anyone know how to turn off the console so I only have the eclipse GUI and not the console window? I'm running MS Windows 7.
I want my jobs to execute in every X seconds, there's one to one matching between job and X. Also during runtime there can be registered new jobs with their own intervals.
I've tried to write cron expression for such scenarios, but in documentation there's written that value of seconds can't be more than 69. So cron expression like this: "0/63 * * * * ?" isn't valid.
At first sight solution of that problem seemed to be expression like this: "0/3 0/1 * * * ?", but it means completely different thing: trigger job in every three second of every minute.
Can you suggest what is the right solution (cron expression) for that? I know I could use just simple timers, but I've to use cron jobs using Quartz.
Hello,
I've read somewhere that when a session is flushed or a transaction is committed, the session itself is closed by Hibernate. So, how can i reuse an Hibernate Session, in the same thread, that has been previously closed?
Thanks
I have several child classes that extend a parent class, forced to have a uniform constructor. I have a queue which keeps a list of these classes, which must extend MergeHeuristic. The code that I currently have looks like the following:
Class<? extends MergeHeuristic> heuristicRequest = _heuristicQueue.pop();
MergeHeuristic heuristic = null;
if(heuristicRequest == AdjacentMACs.class)
heuristic = new AdjacentMACs(_parent);
if(heuristicRequest == SimilarInterfaceNames.class)
heuristic = new SimilarInterfaceNames(_parent);
if(heuristicRequest == SameMAC.class)
heuristic = new SameMAC(_parent);
Is there any way to simplify that to dynamically instantiate the class, something along the lines of:
heuristic = new heuristicRequest.somethingSpecial();
That would flatten that block of if statements.
So i'm trying to send a String[] Array/List over an open socket connection. I currently have this code:
Sending:
public void sendData() {
try {
OutputStream socketStream = socket.getOutputStream();
ObjectOutputStream objectOutput = new ObjectOutputStream(socketStream);
objectOutput.writeObject(new String[] {"Test", "Test2", "Test3"});
objectOutput.close();
socketStream.close();
} catch (Exception e) {
System.out.println(e.toString());
}
}
Recieving:
public Object readData() {
try {
InputStream socketStream = socket.getInputStream();
ObjectInputStream objectInput = new ObjectInputStream(new GZIPInputStream(socketStream));
Object a = objectInput.readObject();
return a;
} catch(Exception e) {
return null;
}
}
After I have recieved the String array/list on the other end I want to be able to iterate through it like I would do normally so I can get the values. My current code doesn't seem to works as it returns null as the value.
is this possible?
I have a string of a variable length and at the end of the string are some digits. What would be the best / efficient way, to parse the string and get the number from the end as an Integer?
The String and the digits at the end can can be of any length. For example:
abcd123 -- 123
abc12345 -- 12345
ab4cd1 -- 1
I know my RMI app works correctly - it works fine when the server is on localhost and inside the LAN but when connecting to an external RMI server it fails when trying to make stub calls
So the server is bound to localhost (an internal IP - 192.168.1.73) but the client is specifying an external IP (45.4.234.56) - which then gets forwarded to the internal server. How do you resolve this problem?
thanks
hi i have class called userdata which returns the Userarraylist which is of type User. when ever i try to use contains method to check particular property is existing or not it always returns false why?
Actually i want the array list to be generic which should return the objects that are set in array list.
String className = data.getUserData().get(0).getClass().getSimpleName();
if(className.equalsIgnoreCase("User")) {
ArrayList<User> userdata=new ArrayList();
userdata = data.getUserData();
System.out.println(data.getUserData().contains(u.getUserId()));
if(userdata.contains(u.getUserName())) {
System.out.println(userdata.get(0).getEmailId());
}
}
I want to show an arrow that indicates the direction towards a goal, using the orientation sensor and current GPS position. Everything works well, except that I want to rotate the arrow image in my ImageView.
The current code, which shows the arrow pointing upwards, is this:
ImageViewArrow.setImageResource(R.drawable.arrow);
What is the best solution for showing the arrow, rotated by N degrees?
I'm planning on doing a application for Android 2.1 that changes song every minute (through what I hope exists in Android, "next") for the application using the audio device atm.
So if I have Spotify running in background already, playing music, can I through my program change to the next track?
Let me know if I was unclear about anything.
Thanks in advance!
I am trying to create new object of other class in a for loop. like
for(int i =0;i<10;i++){
Computer p1=new Computer(10,20);
}
and when I try anywhere to reach p1.someAction(); it say you must declare p1. But if I declare it on top of program how can I create again in loop? I also try only Computer p1; but it gave exeption ..