Search Results

Search found 5375 results on 215 pages for 'jeremy person'.

Page 6/215 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • With Eclipselink/JPA, can I have a Foreign Composite Key that shares a field with a Primary Composit

    - by user107924
    My database has two entities; Company and Person. A Company can have many People, but a Person must have only one Company. The table structure looks as follows. COMPANY ---------- owner PK comp_id PK c_name PERSON ---------------- owner PK, FK1 personid PK comp_id FK1 p_fname p_sname It has occurred to me that I could remove PERSON.OWNER and derive it through the foreign key; however, I can't make this change without affecting legacy code. I have modeled these as JPA-annotated classes; @Entity @Table(name = "PERSON") @IdClass(PersonPK.class) public class Person implements Serializable { @Id private String owner; @Id private String personid; @ManyToOne @JoinColumns( {@JoinColumn(name = "owner", referencedColumnName = "OWNER", insertable = false, updatable = false), @JoinColumn(name = "comp_id", referencedColumnName = "COMP_ID", insertable = true, updatable = true)}) private Company company; private String p_fname; private String p_sname; ...and standard getters/setters... } @Entity @Table(name = "COMPANY") @IdClass(CompanyPK.class) public class Company implements Serializable { @Id private String owner; @Id private String comp_id; private String c_name; @OneToMany(mappedBy = "company", cascade=CascadeType.ALL) private List people; ...and standard getters/setters... } My PersonPK and CompanyPK classes are nothing special, they just serve as a struct holding owner and the ID field, and override hashCode and equals(o). So far so good. I come across a problem, however, when trying to deal with associations. It seems if I have an existing Company, and create a Person, and associate to the Person to the Company and persist the company, the association is not saved when the Person is inserted. For example, my main code looks like this: EntityManager em = emf.createEntityManager(); em.getTransaction().begin(); CompanyPK companyPK = new CompanyPK(); companyPK.owner="USA"; companyPK.comp_id="1102F3"; Company company = em.find(Company.class, companyPK); Person person = new Person(); person.setOwner("USA"); person.setPersonid("5116628123"); //some number that doesn't exist yet person.setP_fname("Hannah"); person.setP_sname("Montana"); person.setCompany(company); em.persist(person); This completes without error; however in the database I find that the Person record was inserted with a null in the COMP_ID field. With EclipseLink debug logging set to FINE, the SQL query is shown as: INSERT INTO PERSON (PERSONID,OWNER,P_SNAME,P_FNAME) VALUES (?,?,?,?) bind = [5116628123,USA,Montana,Hannah,] I would have expected this to be saved, and the query to be equivalent to INSERT INTO PERSON (PERSONID,OWNER,COMP_ID,P_SNAME,P_FNAME) VALUES (?,?,?,?,?) bind = [5116628123,USA,1102F3,Montana,Hannah,] What gives? Is it incorrect to say updatable/insertable=true for one half of a composite key and =false for the other half? If I have updatable/insertable=true for both parts of the foreign key, then Eclipselink fails to startup saying that I can not use the column twice without having one set to readonly by specifying these options.

    Read the article

  • Grails checkbox

    - by Tomáš
    Hi gurus I have trouble with binding Boolean property in association classes. Property is set to true if I check checkbox (good), but is null if checbox is not checked. I know the problem with HTML checkbox. I know why is send "_fieldName" in params, but this "_fieldName" dont set my boolean property to false. class Person{ String title List<Group> groups = new ArrayList() static hasMany = [groups: Groups] } class Group{ String title Boolean isHidden static belongTo = Person } class PersonController{ def form = { def person = new Person() person.groups.add( new Group() ) return ["person": person] } def handleForm = { def person = new Person( params ) println person.groups[0] } } If I check checkbox: [isHidden:on, title:a, _isHidden:] println person.groups[0] //true If I don check checkbox: [title:a, _isHidden:] println person.groups[0] //null Thank a lot for help Tom I am sorry, I searched this web, but did not get actual info for my trouble.

    Read the article

  • Can someone here explain constructors and destructors in python - simple explanation required - new

    - by rgolwalkar
    i will try to see if it makes sense :- class Person: '''Represnts a person ''' population = 0 def __init__(self,name): //some statements and population += 1 def __del__(self): //some statements and population -= 1 def sayHi(self): '''grettings from person''' print 'Hi My name is %s' % self.name def howMany(self): '''Prints the current population''' if Person.population == 1: print 'i am the only one here' else: print 'There are still %d guyz left ' % Person.population rohan = Person('Rohan') rohan.sayHi() rohan.howMany() sanju = Person('Sanjivi') sanju.howMany() del rohan # am i doing this correctly --- ? i need to get an explanation for this del - destructor O/P:- Initializing person data ****************************************** Initializing Rohan ****************************************** Population now is: 1 Hi My name is Rohan i am the only one here Initializing person data ****************************************** Initializing Sanjivi ****************************************** Population now is: 2 In case Person dies: ****************************************** Sanjivi Bye Bye world there are still 1 people left i am the only one here In case Person dies: ****************************************** Rohan Bye Bye world i am the last person on earth Population now is: 0 If required i can paste the whole lesson as well --- learning from :- http://www.ibiblio.org/swaroopch/byteofpython/read/

    Read the article

  • python __getattr__ help

    - by Stefanos Tux Zacharakis
    Reading a Book, i came across this code... # module person.py class Person: def __init__(self, name, job=None, pay=0): self.name = name self.job = job self.pay = pay def lastName(self): return self.name.split()[-1] def giveRaise(self, percent): self.pay = int(self.pay *(1 + percent)) def __str__(self): return "[Person: %s, %s]" % (self.name,self.pay) class Manager(): def __init__(self, name, pay): self.person = Person(name, "mgr", pay) def giveRaise(self, percent, bonus=.10): self.person.giveRaise(percent + bonus) def __getattr__(self, attr): return getattr(self.person, attr) def __str__(self): return str(self.person) It does what I want it to do, but i do not understand the __getattr__ function in the Manager class. I know that it Delegates all other attributes from Person class. but I do not understand the way it works. for example why from Person class? as I do not explicitly tell it to. person(module is different than Person(class) Any help is highly appreciated :)

    Read the article

  • Static variables in Java for a test oObject creator

    - by stevebot
    Hey, I have something like the following TestObjectCreator{ private static Person person; private static Company company; static { person = new Person() person.setName("Joe"); company = new Company(); company.setName("Apple"); } public Person createTestPerson(){ return person; } public Person createTestCompany(){ return company; } } By applying static{} what am I gaining? I assume the objects are singletons as a result. However, if I did the following: Person person = TestObjectCreator.createTestPerson(); person.setName("Jill"); Person person2 = TestObjectCreator.createTestPerson(); would person2 be named Jill or Joe?

    Read the article

  • How to optimise MySQL query containing a subquery?

    - by aidan
    I have two tables, House and Person. For any row in House, there can be 0, 1 or many corresponding rows in Person. But, of those people, a maximum of one will have a status of "ACTIVE", the others will all have a status of "CANCELLED". e.g. SELECT * FROM House LEFT JOIN Person ON House.ID = Person.HouseID House.ID | Person.ID | Person.Status 1 | 1 | CANCELLED 1 | 2 | CANCELLED 1 | 3 | ACTIVE 2 | 1 | ACTIVE 3 | NULL | NULL 4 | 4 | CANCELLED I want to filter out the cancelled rows, and get something like this: House.ID | Person.ID | Person.Status 1 | 3 | ACTIVE 2 | 1 | ACTIVE 3 | NULL | NULL 4 | NULL | NULL I've achieved this with the following sub select: SELECT * FROM House LEFT JOIN ( SELECT * FROM Person WHERE Person.Status != "CANCELLED" ) Person ON House.ID = Person.HouseID ...which works, but breaks all the indexes. Is there a better solution that doesn't? I'm using MySQL and all relevant columns are indexed. EXPLAIN lists nothing in possible_keys. Thanks.

    Read the article

  • How to write two-dimensional array to xml in Scala 2.8.0

    - by Shadowlands
    The following code (copied from a question from about a year ago) works fine under Scala 2.7.7, but does not behave correctly under Scala 2.8.0 (Beta 1, RC8). import scala.xml class Person(name : String, age : Int) { def toXml(): xml.Elem = <person><name>{ name }</name><age>{ age }</age></person> } def peopleToXml(people: Array[Person]): xml.Elem = { <people>{ for {person <- people} yield person.toXml }</people> } val data = Array(new Person("joe",40), new Person("mary", 35)) println(peopleToXml(data)) The output (according to 2.7.7) should be: <people><person><name>joe</name><age>40</age></person><person><name>mary</name><age>35</age></person></people> but instead comes out as: <people>\[Lscala.xml.Elem;@17821782</people> How do I get this to behave as it did in 2.7.x?

    Read the article

  • inheritance problem OOP extend

    - by hsmit
    If a Father is a Parent and a Parent is a Person and a Person has a Father I create the following: class Person{ Father father; } class Parent extends Person{} class Father extends Parent{} Instances: Person p1 = new Person(); Person p2 = new Person(); p1.father = p2; //father is of the type Father This doesn't work... Now try casting:: Person p1 = new Person(); Person p2 = new Person(); p1.father = (Father)p2; This doesn't work either. What does work for this case?

    Read the article

  • Saving data in custom class via AppDelegate

    - by redspike
    I can't seem to save data to a custom instance object in my AppDelegate. My custom class is very simple and is as follows: Person.h ... @interface Person : NSObject { int _age; } - (void) setAge: (int) age; - (int) age; @end Person.m #import "Person.h" @implementation Person - (void) setAge:(int) age { _age = age; } - (int) age { return _age; } @end I then create an instance of Person in the AppDelegate class: AppDelegate.h @class Person; @interface AccuTaxAppDelegate : NSObject <UIApplicationDelegate> { ... Person *person; } ... @property (nonatomic, retain) Person *person; @end AppDelegate.m ... #import "Person.h" @implementation AccuTaxAppDelegate ... @synthesize person; - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [window addSubview:[navigationController view]]; [window makeKeyAndVisible]; } - (void)applicationWillTerminate:(UIApplication *)application { // Save data if appropriate } #pragma mark - #pragma mark Memory management - (void)dealloc { [navigationController release]; [window release]; [person release]; [super dealloc]; } @end Finally, in my ViewController code I grab a handle on AppDelegate and then grab the person instance, but when I try to save the age it doesn't seem to work: MyViewController ... - (void)textFieldDidEndEditing:(UITextField *)textField { NSString *textAge = [textField text]; int age = [textAge intValue]; NSLog(@"Age from text field::%i", age); AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; Person *myPerson = (Person *)[appDelegate person]; NSLog(@"Age before setting: %i", [myPerson age]); [myPerson setAge:age]; NSLog(@"Age after setting: %i", [myPerson age]); [textAge release]; } ... The output of the above NSLogs are: [Session started at 2010-05-04 18:29:22 +0100.] 2010-05-04 18:29:28.260 AccuTax[16235:207] Age in text field:25 2010-05-04 18:29:28.262 AccuTax[16235:207] Age before setting: 0 2010-05-04 18:29:28.263 AccuTax[16235:207] Age after setting: 0 Any ideas why 'age' isn't being stored? I'm relatively new to Obj-C so please forgive me if I'm missing something very simple!

    Read the article

  • VirtualBox guest responds to ping but all ports closed in nmap

    - by jeremyjjbrown
    I want to setup a test database on a vm for development purposes but I cannot connect to the server via the network. I've got Ubuntu 12.04vm installed on 12.04 host in Virtualbox 4.2.4 set to - Bridged network mode - Promiscuous Allow All When I try to ping the virtual guest from any network client I get the expected result. PING 192.168.1.209 (192.168.1.209) 56(84) bytes of data. 64 bytes from 192.168.1.209: icmp_req=1 ttl=64 time=0.427 ms ... Internet access inside the vm is normal But when I nmap it I get nothin! jeremy@bangkok:~$ nmap -sV -p 1-65535 192.168.1.209 Starting Nmap 5.21 ( http://nmap.org ) at 2012-11-15 18:39 CST Nmap scan report for jeremy (192.168.1.209) Host is up (0.0032s latency). All 65535 scanned ports on jeremy (192.168.1.209) are closed Service detection performed. Please report any incorrect results at http://nmap.org/submit/ Nmap done: 1 IP address (1 host up) scanned in 0.88 seconds ufw and iptables on VM... jeremy@jeremy:~$ sudo service ufw stop [sudo] password for jeremy: ufw stop/waiting jeremy@jeremy:~$ sudo iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination I have scanned around and have no reason to believe that my router is blocking internal ports. jeremy@bangkok:~$ nmap -v 192.168.1.2 Starting Nmap 5.21 ( http://nmap.org ) at 2012-11-15 18:44 CST Initiating Ping Scan at 18:44 Scanning 192.168.1.2 [2 ports] Completed Ping Scan at 18:44, 0.00s elapsed (1 total hosts) Initiating Parallel DNS resolution of 1 host. at 18:44 Completed Parallel DNS resolution of 1 host. at 18:44, 0.03s elapsed Initiating Connect Scan at 18:44 Scanning 192.168.1.2 [1000 ports] Discovered open port 445/tcp on 192.168.1.2 Discovered open port 139/tcp on 192.168.1.2 Discovered open port 3306/tcp on 192.168.1.2 Discovered open port 80/tcp on 192.168.1.2 Discovered open port 111/tcp on 192.168.1.2 Discovered open port 53/tcp on 192.168.1.2 Discovered open port 5902/tcp on 192.168.1.2 Discovered open port 8090/tcp on 192.168.1.2 Discovered open port 6881/tcp on 192.168.1.2 Completed Connect Scan at 18:44, 0.02s elapsed (1000 total ports) Nmap scan report for 192.168.1.2 Host is up (0.0017s latency). Not shown: 991 closed ports PORT STATE SERVICE 53/tcp open domain 80/tcp open http 111/tcp open rpcbind 139/tcp open netbios-ssn 445/tcp open microsoft-ds 3306/tcp open mysql 5902/tcp open vnc-2 6881/tcp open bittorrent-tracker 8090/tcp open unknown Read data files from: /usr/share/nmap Nmap done: 1 IP address (1 host up) scanned in 0.08 seconds Answer... Turns out all of the ports were open to the network. I installed open ssh and confirmed it. Then I edited my db conf to listen to external IP's and all was well.

    Read the article

  • How do you explain refactoring to a non-technical person?

    - by Benjol
    (This question was inspired by the most-voted answer here) How do you go about explaining refactoring (and technical debt) to a non-technical person (typically a PHB or customer)? ("What, it's going to cost me a month of your work with no visible difference?!") UPDATE Thanks for all the answers so far, I think this list will provide several useful analogies to which we can point the appropriate people (though editing out references to PHBs may be wise!)

    Read the article

  • How do you explain refactoring to a non-technical person?

    - by Benjol
    (This question was inspired by the most-voted answer here) How do you go about explaining refactoring (and technical debt) to a non-technical person (typically a PHB or customer)? ("What, it's going to cost me a month of your work with no visible difference?!") UPDATE Thanks for all the answers so far, I think this list will provide several useful analogies to which we can point the appropriate people (though editing out references to PHBs may be wise!)

    Read the article

  • getting record from CoreData ?

    - by Meko
    Hi. I am trying to add value to CoreData from .plist and get from coreData and show them on UITable. I made take from .plist and send them to CoreData .But I cant take them from CoreData entity and set to some NSMutable array.. Here my codes Edit : SOLVED NSString *path = [[NSBundle mainBundle] pathForResource:@"FakeData" ofType:@"plist"]; NSArray *myArray=[[NSArray alloc] initWithContentsOfFile:path]; FlickrFetcher *flickrfetcher =[FlickrFetcher sharedInstance]; managedObjectContext =[flickrfetcher managedObjectContext]; for(NSDictionary *dict in myArray){ Photo *newPhoto = (Photo *)[NSEntityDescription insertNewObjectForEntityForName:@"Photo" inManagedObjectContext:managedObjectContext]; // set the attributes for the photo NSLog(@"Creating Photo: %@", [dict objectForKey:@"name"]); [newPhoto setName:[dict objectForKey:@"name"]]; [newPhoto setPath:[dict objectForKey:@"path"]]; NSLog(@"Person is: %@", [dict objectForKey:@"user"]); NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name ==%@",[dict objectForKey:@"user"]]; NSMutableArray *peopleArray = (NSMutableArray *)[flickrfetcher fetchManagedObjectsForEntity:@"Person" withPredicate:predicate]; NSEnumerator *enumerator = [peopleArray objectEnumerator]; Person *person; BOOL exists = FALSE; while (person = [enumerator nextObject]) { NSLog(@" Person is: %@ ", person.name); if([person.name isEqualToString:[dict objectForKey:@"user"]]) { exists = TRUE; NSLog(@"-- Person Exists : %@--", person.name); [newPhoto setPerson:person]; } } // if person does not already exist then add the person if (!exists) { Person *newPerson = (Person *)[NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:managedObjectContext]; // create the person [newPerson setName:[dict objectForKey:@"user"]]; NSLog(@"-- Person Created : %@--", newPerson.name); // associate the person with the photo [newPhoto setPerson:newPerson]; } //THis IS myArray that I want to save value in it and them show them in UITABLE personList=[[NSMutableArray alloc]init]; NSLog(@"lllll %@",[personList objectAtIndex:0]); // save the data NSError *error; if (![managedObjectContext save:&error]) { // Handle the error. NSLog(@"Unresolved error %@, %@", error, [error userInfo]); exit(-1); } } //To access core data objects you can try the following: // setup our fetchedResultsController fetchedResultsController = [flickrfetcher fetchedResultsControllerForEntity:@"Person" withPredicate:nil]; // execute the fetch NSError *error; BOOL success = [fetchedResultsController performFetch:&error]; if (!success) { // Handle the error. NSLog(@"Unresolved error %@, %@", error, [error userInfo]); exit(-1); } // save our data //HERE PROBLEM THAT I DONW KNOW WHERE IT IS SAVING //[personList addObject:(NSMutableArray *)[fetchedResultsController fetchedObjects]]; [self setPersonList:(NSMutableArray *)[fetchedResultsController fetchedObjects]]; } Here my tableview function - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"ss %d",[personList count]); static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text=[personList objectAtIndex:indexPath.row]; // Set up the cell... return cell; }

    Read the article

  • Before and After the Programmer Life [closed]

    - by Gio Borje
    How were people before and after becoming programmers through a black box? In a black box, the implementation is irrelevant; therefore, we focus on the input and output: High School Nerd -> becomeProgrammer() -> Manager (Person Before) -> (Person as Programmer) -> (New Person) (Person Before) -> (Person as Programmer) How are the typical lives of people before they became programmers? Why do people pursue life as a programmer? (Person as Programmer) -> (New Person) How has becoming a programmer changed people afterwards? Why quit being a programmer? Anecdotes would be nice. If many programmers have similar backgrounds and fates, do you think that there is some sort of stereotypical person that are destined to become programmers?

    Read the article

  • Why does DataContractJsonSerializer not include generic like JavaScriptSerializer?

    - by Patrick Magee
    So the JavaScriptSerializer was deprecated in favor of the DataContractJsonSerializer. var client = new WebClient(); var json = await client.DownloadStringTaskAsync(url); // http://example.com/api/people/1 // Deprecated, but clean looking and generally fits in nicely with // other code in my app domain that makes use of generics var serializer = new JavaScriptSerializer(); Person p = serializer.Deserialize<Person>(json); // Now have to make use of ugly typeof to get the Type when I // already know the Type at compile type. Why no Generic type T? var serializer = new DataContractJsonSerializer(typeof(Person)); Person p = serializer.ReadObject(json) as Person; The JavaScriptSerializer is nice and allows you to deserialize using a type of T generic in the function name. Understandably, it's been deprecated for good reason, with the DataContractJsonSerializer, you can decorate your Type to be deserialized with various things so it isn't so brittle like the JavaScriptSerializer, for example [DataMember(name = "personName")] public string Name { get; set; } Is there a particular reason why they decided to only allow users to pass in the Type? Type type = typeof(Person); var serializer = new DataContractJsonSerializer(type); Person p = serializer.ReadObject(json) as Person; Why not this? var serializer = new DataContractJsonSerializer(); Person p = serializer.ReadObject<Person>(json); They can still use reflection with the DataContract decorated attributes based on the T that I've specified on the .ReadObject<T>(json)

    Read the article

  • Object desing problem for simple school application

    - by Aragornx
    I want to create simple school application that provides grades,notes,presence,etc. for students,teachers and parents. I'm trying to design objects for this problem and I'm little bit confused - because I'm not very experienced in class designing. Some of my present objects are : class PersonalData() { private String name; private String surename; private Calendar dateOfBirth; [...] } class Person { private PersonalData personalData; } class User extends Person { private String login; private char[] password; } class Student extends Person { private ArrayList<Counselor> counselors = new ArrayList<>(); } class Counselor extends Person { private ArrayList<Student> children = new ArrayList<>(); } class Teacher extends Person { private ArrayList<ChoolClass> schoolClasses = new ArrayList<>(); private ArrayList<Subject> subjects = new ArrayList<>(); } This is of course a general idea. But I'm sure it's not the best way. For example I want that one person could be a Teacher and also a Parent(Counselor) and present approach makes me to have two Person objects. I want that user after successful logging in get all roles that it has (Student or Teacher or (Teacher & Parent) ). I think I should make and use some interfaces but I'm not sure how to do this right. Maybe like this: interface Role { } interface TeacherRole implements Role { void addGrade( Student student, Grade grade, [...] ); } class Teacher implements TeacherRole { private Person person; [...] } class User extends Person{ ArrayList<Role> roles = new ArrayList<>(); } Please if anyone could help me to make this right or maybe just point me to some literature/article that covers practical objects design.

    Read the article

  • Pointers to class fields

    - by newbie_cpp
    My task is as follows : Using pointers to class fields, create menu allowing selection of ice, that Person can buy in Ice shop. Buyer will be charged with waffel and ice costs. Selection of ice and charging buyers account must be shown in program. Here's my Person class : #include <iostream> using namespace std; class Iceshop { const double waffel_price = 1; public: } class Person { static int NUMBER; char* name; int age; const int number; double plus, minus; public: class Account { int number; double resources; public: Account(int number, double resources) : number(number), resources(resources) {} } Person(const char* n, int age) : name(strcpy(new char[strlen(n)+1],n)), number(++NUMBER), plus(0), minus(0), age(age) {} Person::~Person(){ cout << "Destroying resources" << endl; delete [] name; } friend void show(Person &p); int* take_age(){ return &age; } char* take_name(){ return name; } void init(char* n, int a) { name = n; age = a; } Person& remittance(double d) { plus += d; return *this; } Person& paycheck(double d) { minus += d; return *this; } Account* getAccount(); }; int Person:: Person::Account* Person::getAccount() { return new Account(number, plus - minus); } void Person::Account::remittance(double d){ resources = resources + d; } void Person::Account::paycheck(double d){ resources = resources - d; } void show(Person *p){ cout << "Name: " << p->take_name() << "," << "age: " << p->take_age() << endl; } int main(void) { Person *p = new Person; p->init("Mary", 25); show(p); p->remittance(100); system("PAUSE"); return 0; } How to start this task ? Where and in what form should I store menu options ?

    Read the article

  • hibernate annotation- extending base class - values are not being set - strange error

    - by gt_ebuddy
    I was following Hibernate: Use a Base Class to Map Common Fields and openjpa inheritance tutorial to put common columns like ID, lastModifiedDate etc in base table. My annotated mappings are as follow : BaseTable : @MappedSuperclass public abstract class BaseTable { @Id @GeneratedValue @Column(name = "id") private int id; @Column(name = "lastmodifieddate") private Date lastModifiedDate; ... Person table - @Entity @Table(name = "Person ") public class Person extends BaseTable implements Serializable{ ... Create statement generated : create table Person (id integer not null auto_increment, lastmodifieddate datetime, name varchar(255), primary key (id)) ; After I save a Person object to db, Person p = new Person(); p.setName("Test"); p.setLastModifiedDate(new Date()); .. getSession().save(p); I am setting the date field but, it is saving the record with generated ID and LastModifiedDate = null, and Name="Test". Insert Statement : insert into Person (lastmodifieddate, name) values (?, ?) binding parameter [1] as [TIMESTAMP] - <null> binding parameter [2] as [VARCHAR] - Test Read by ID query : When I do hibernate query (get By ID) as below, It reads person by given ID. Criteria c = getSession().createCriteria(Person.class); c.add(Restrictions.eq("id", id)); Person person= c.list().get(0); //person has generated ID, LastModifiedDate is null select query select person0_.id as id8_, person0_.lastmodifieddate as lastmodi8_, person0_.name as person8_ from Person person0_ - Found [1] as column [id8_] - Found [null] as column [lastmodi8_] - Found [Test] as column [person8_] ReadAll query : //read all Query query = getSession().createQuery("from " + Person.class.getName()); List allPersons=query.list(); Corresponding SQL for read all select query select person0_.id as id8_, person0_.lastmodifieddate as lastmodi8_, person0_.name as person8_ from Person person0_ - Found [1] as column [id8_] - Found [null] as column [lastmodi8_] - Found [Test] as column [person8_] - Found [2] as column [id8_] - Found [null] as column [lastmodi8_] - Found [Test2] as column [person8_] But when I print out the list in console, its being more weird. it is selecting List of Person object with ID fields = all 0 (why all 0 ?) LastModifiedDate = null Name fields have valid values I don't know whats wrong here. Could you please look at it? FYI, My Hibernate-core version : 4.1.2, MySQL Connector version : 5.1.9 . In summary, There are two issues here Why I am getting All ID Fields =0 when using read all? Why the LastModifiedDate is not being inserted?

    Read the article

  • How to explain to non-technical person why the task will take much longer then they think?

    - by Mag20
    Almost every developer has to answer questions from business side like: Why is going to take 2 days to add this simple contact form? When developer estimates this task, they may divide it into steps: make some changes to Database optimize DB changes for speed add front end HTML write server side code add validation add client side javascript use unit tests make sure SEO is setup is working implement email confirmation refactor and optimize the code for speed ... These maybe hard to explain to non-technical person, who basically sees the whole task as just putting together some HTML and creating a table to store the data. To them it could be 2 hours MAX. So is there a better way to explain why the estimate is high to non-developer?

    Read the article

  • How to explain OOP concepts to a non technical person?

    - by John
    I often try to avoid telling people I'm a programmer because most of the time I end up explaining to them what that really means. When I tell them I'm programming in Java they often ask general questions about the language and how it differs from x and y. I'm also not good at explaining things because 1) I don't have that much experience in the field and 2) I really hate explaining things to non-technical people. They say that you truly understand things once you explain them to someone else, in this case how would you explain OOP terminology and concepts to a non technical person?

    Read the article

  • Distutils - Where Am I going wrong?

    - by RJBrady
    I wanted to learn how to create python packages, so I visited http://docs.python.org/distutils/index.html. For this exercise I'm using Python 2.6.2 on Windows XP. I followed along with the simple example and created a small test project: person/ setup.py person/ __init__.py person.py My person.py file is simple: class Person(object): def __init__(self, name="", age=0): self.name = name self.age = age def sound_off(self): print "%s %d" % (self.name, self.age) And my setup.py file is: from distutils.core import setup setup(name='person', version='0.1', packages=['person'], ) I ran python setup.py sdist and it created MANIFEST, dist/ and build/. Next I ran python setup.py install and it installed it to my site packages directory. I run the python console and can import the person module, but I cannot import the Person class. >>>import person >>>from person import Person Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name Person I checked the files added to site-packages and checked the sys.path in the console, they seem ok. Why can't I import the Person class. Where did I go wrong?

    Read the article

  • Ruby and public_method_defined? : strange behaviour

    - by aXon
    Hi there Whilst reading through the book "The well grounded Rubyist", I came across some strange behaviour. The idea behind the code is using one's own method_missing method. The only thing I am not able to grasp is, why this code gets executed, as I do not have any Person.all_with_* class methods defined, which in turn means that the self.public_method_defined?(attr) returns true (attr is friends and then hobbies). #!/usr/bin/env ruby1.9 class Person PEOPLE = [] attr_reader :name, :hobbies, :friends def initialize(mame) @name = name @hobbies = [] @friends = [] PEOPLE << self end def has_hobby(hobby) @hobbies << hobby end def has_friend(friend) @friends << friend end def self.method_missing(m,*args) method = m.to_s if method.start_with?("all_with_") attr = method[9..-1] if self.public_method_defined?(attr) PEOPLE.find_all do |person| person.send(attr).include?(args[0]) end else raise ArgumentError, "Can't find #{attr}" end else super end end end j = Person.new("John") p = Person.new("Paul") g = Person.new("George") r = Person.new("Ringo") j.has_friend(p) j.has_friend(g) g.has_friend(p) r.has_hobby("rings") Person.all_with_friends(p).each do |person| puts "#{person.name} is friends with #{p.name}" end Person.all_with_hobbies("rings").each do |person| puts "#{person.name} is into rings" end The output is is friends with is friends with is into rings which is really understandable, as there is nothing to be executed.

    Read the article

  • Doubt about instance creation by using Spring framework ???

    - by Arthur Ronald F D Garcia
    Here goes a command object which needs to be populated from a Spring form public class Person { private String name; private Integer age; /** * on-demand initialized */ private Address address; // getter's and setter's } And Address public class Address { private String street; // getter's and setter's } Now suppose the following MultiActionController @Component public class PersonController extends MultiActionController { @Autowired @Qualifier("personRepository") private Repository<Person, Integer> personRepository; /** * mapped To /person/add */ public ModelAndView add(HttpServletRequest request, HttpServletResponse response, Person person) throws Exception { personRepository.add(person); return new ModelAndView("redirect:/home.htm"); } } Because Address attribute of Person needs to be initialized on-demand, i need to override newCommandObject to create an instance of Person to initiaze address property. Otherwise, i will get NullPointerException @Component public class PersonController extends MultiActionController { /** * code as shown above */ @Override public Object newCommandObject(Class clazz) thorws Exception { if(clazz.isAssignableFrom(Person.class)) { Person person = new Person(); person.setAddress(new Address()); return person; } } } Ok, Expert Spring MVC and Web Flow says Options for alternate object creation include pulling an instance from a BeanFactory or using method injection to transparently return a new instance. First option pulling an instance from a BeanFactory can be written as @Override public Object newCommandObject(Class clazz) thorws Exception { /** * Will retrieve a prototype instance from ApplicationContext whose name matchs its clazz.getSimpleName() */ getApplicationContext().getBean(clazz.getSimpleName()); } But what does he want to say by using method injection to transparently return a new instance ??? Can you show how i implement what he said ??? ATT: I know this funcionality can be filled by a SimpleFormController instead of MultiActionController. But it is shown just as an example, nothing else

    Read the article

  • Etiquette for refactoring other people's sourcecode?

    - by Prutswonder
    Our team of software developers consists of a bunch of experienced programmers with a variety of programming styles and preferences. We do not have standards for everything, just the bare necessities to prevent total chaos. Recently, I bumped into some refactoring done by a colleague. My code looked somewhat like this: public Person CreateNewPerson(string firstName, string lastName) { var person = new Person() { FirstName = firstName, LastName = lastName }; return person; } Which was refactored to this: public Person CreateNewPerson (string firstName, string lastName) { Person person = new Person (); person.FirstName = firstName; person.LastName = lastName; return person; } Just because my colleague needed to update some other method in one of the classes I wrote, he also "refactored" the method above. For the record, he's one of those developers that despises syntactic sugar and uses a different bracket placement/identation scheme than the rest of us. My question is: What is the (C#) programmer's etiquette for refactoring other people's sourcecode (both semantic and syntactic)?

    Read the article

  • Function Object in Java .

    - by Tony
    I wanna implement a javascript like method in java , is this possible ? Say , I have a Person class : public class Person { private String name ; private int age ; // constructor ,accessors are omitted } And a list with Person objects: Person p1 = new Person("Jenny",20); Person p2 = new Person("Kate",22); List<Person> pList = Arrays.asList(new Person[] {p1,p2}); I wanna implement a method like this: modList(pList,new Operation (Person p) { incrementAge(Person p) { p.setAge(p.getAge() + 1)}; }); modList receives two params , one is a list , the other is the "Function object", it loops the list ,and apply this function to every element in the list. In functional programming language,this is easy , I don't know how java do this? Maybe could be done through dynamic proxy, does that have a performance trade off?

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >