Search Results

Search found 414 results on 17 pages for 'enums'.

Page 9/17 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Mapping enum to a table with hibernate annotation

    - by Thierry-Dimitri Roy
    I have a table DEAL and a table DEAL_TYPE. I would like to map this code: public class Deal { DealType type; } public enum DealType { BASE("Base"), EXTRA("Extra"); } The problem is that the data already exist in the database. And I'm having a hard time mapping the classes to the database. The database looks something like that: TABLE DEAL { Long id; Long typeId; } TABLE DEAL_TYPE { Long id; String text; } I know I could use a simple @OneToMany relationship from deal to deal type, but I would prefer to use an enum. Is this possible? I almost got it working by using a EnumType.ORDINAL type. But unfortunately, my IDs in my deal type table are not sequential, and do not start at 1. Any suggestions?

    Read the article

  • Passing a enum value as a tag attribute in JSP

    - by Jakub
    I have a custom JSP tag which is using a parameter which is an enum. This approach is a consequence of using other classes which need this enumeration. The point is I have no clue how to assign an enum value in the EL: <mytaglib:mytag enumParam="${now what do I type here?}" /> The only workaround which I found so far was to make the enumParam an Integer and convert it to desired values: <mytaglib:mytag enumParam="3" /> I believe there must be a better way to do it. Please help.

    Read the article

  • Iphone -- maintaining a list of strings and a corresponding typedef enum

    - by William Jockusch
    Suppose I have the following: typedef enum functionType {ln, sin, sqrt} functionType; NSArray *functions = [NSArray arrayWithObjects: @"ln", @"sin", @"sqrt", nil]; Suppose further that *functions will not change at runtime. Question -- is there any way to set up a single structure which updates both of these? So that I only have to keep track of one list, instead of two. To explain what is going on -- the idea is that string input from the user will be stored in a variable of type functionType. Later on, I will have code like this: double valueOfFunction: (functionType) function withInput: (double) input switch (function) { case ln: return ln(input); case sin: return sin(input); case sqrt: return sqrt(input); //etc . . . could grow to include a lot of functions. } And valueOfFunction needs to be fast. So I don't want to be doing string comparisons there.

    Read the article

  • What is the best way to store categorical references in SQL tables?

    - by jlafay
    I'm wanting to store a wide array of categorical data in MySQL database tables. Let's say that for instance I want to to information on "widgets" and want to categorize attributes in certain ways, i.e. shape category. For instance, the widgets could be classified as: round, square, triangular, spherical, etc. Should these categories be stored within a table to reference them best from an application? Another possibility, I would imagine, would be to add a column to widgets that contained a shape column that contained a tiny int. That way my application could search shapes by that and then use a coordinating enum type that would map the shape int meanings. Which would be best? Or is there another solution that I'm not thinking of yet?

    Read the article

  • Java cannot find symbol enum

    - by JDelage
    Hi, I'm modeling a chess game on Java, and I'm having some problem. Here's what the code looks like (the relevant parts): Enum class Couleur.java: public enum Couleur {BLANC, NOIR} Piece.java: public abstract class Piece { (...) public Piece(Couleur couleurParam){ this.couleurPiece = couleurParam; } (...) } And finally Tour.java: public class Tour extends Piece { (...) public Tour(Couleur couleurParam){ super(couleurParam); } (...) } All the .java files are in the same folder. Yet at compile I get a "cannot find symbol symbol : variable NOIR location: class Plateau" (Plateau is the class that instantiates Tour.) Can anyone help me figure out what's wrong here? Many thanks, JDelage

    Read the article

  • C# cross class enum visibility - Possible?

    - by 537mfb
    so i have a class ClassA that contains an enum MyEnum, and a class ClassB that references that class (different Projects) and so in ClassB i have a using ClassA; clause and i can access that enum using something like MyEnum value = MyEnum.EnumValue; Now on a third project i have my Windows form and it has a clause like using ClassB; Now what can i add in ClassB to acess that enum on my windows Form? Is it even Possible? i would like to avoid having to add ClassA to my form just to access an enum. The idea is that ClassB is sort of a manager between my form and the functionality in ClassA - but i would like to get access to that enum as it makes a lot of tasks easier

    Read the article

  • Having duplicate enumerator values

    - by whirlwin
    I'm creating a Tetris clone in C++, and I have an enum GameProperty, which is specified as follows: enum GameProperty { NUM_OF_TETROMINOES = 7, NUM_OF_TILES = 4, TETROMINO_ROTATIONS = 4 }; In my case, I only use these values when looping through a tetromino's tiles, e.g: for (int i = 0; i < TETROMINO_TILES; i++) { } Is it under any circumstance considered bad practice to have multiple enumerators with the same value?

    Read the article

  • C++ packing a typdef enum

    - by Sagar
    typedef enum BeNeLux { BELGIUM, NETHERLANDS, LUXEMBURG } _PACKAGE_ BeNeLux; When I try to compile this with C++ Compiler, I am getting errors, but it seems to work fine with a C compiler. So here's the question. Is it possible to pack an enum in C++, or can someone see why I would get the error? The error is: "semicolon missing after declaration of BeNeLux". I know, after checking and rechecking, that there definitely is a semicolon there, and in any places required in the rest of the code.

    Read the article

  • Forward declaring an enum in c++

    - by szevvy
    Hi guys, I'm trying to do something like the following: enum E; void Foo(E e); enum E {A, B, C}; which the compiler rejects. I've had a quick look on Google and the consensus seems to be "you can't do it", but I can't understand why. Can anyone explain? Many thanks. Clarification 2: I'm doing this as I have private methods in a class that take said enum, and I do not want the enum's values exposed - so, for example, I do not want anyone to know that E is defined as enum E { FUNCTIONALITY_NORMAL, FUNCTIONALITY_RESTRICTED, FUNCTIONALITY_FOR_PROJECT_X } as project X is not something I want my users to know about. So, I wanted to forward declare the enum so I could put the private methods in the header file, declare the enum internally in the cpp, and distribute the built library file and header to people. As for the compiler - it's GCC.

    Read the article

  • IntelliSense: expression must have integral or enum type

    - by user1743737
    Guys i need someone fix this problem ? when i compile that code i have this error: Error: IntelliSense: expression must have integral or enum type i have problem in this part: Console(0, V("seta sv_hostname " + servername + ";\n")); so how i can fix that if (strncmp(command, V("exec config_mp"), 14) == 0) { if (GAME_MODE == 'D') { CIniReader iniReader(V(".\\teknogods.ini")); char *servername = iniReader.ReadString(V("Settings"),V("Servername"),""); if (strcmp(servername,"") == 0) { info("Server name set to defult."); } else { //Console(0, V("seta scr_teambalance 1;\n")); Console(0, V("seta sv_hostname " + servername + ";\n")); info("server name set to: %s.", servername); } } }

    Read the article

  • How to find the class object of Java generic type?

    - by Samuel Yung
    Assume I have a generic type P which is an Enum, that is <P extends Enum<P>>, and I want to get the Enum value from a string, for example: String foo = "foo"; P fooEnum = Enum.valueOf(P.class, foo); This will get a compile error because P.class is invalid. So what can I do in order to make the above code work?

    Read the article

  • How to use switch statement with Enumerations C#

    - by Maximus Decimus
    I want to use a switch statement in order to avoid many if's. So I did this: public enum Protocol { Http, Ftp } string strProtocolType = GetProtocolTypeFromDB(); switch (strProtocolType) { case Protocol.Http: { break; } case Protocol.Ftp: { break; } } but I have a problem of comparing an Enum and a String. So if I added Protocol.Http.ToString() there is another error because it allows only CONSTANT evaluation. If I change it to this switch (Enum.Parse(typeof(Protocol), strProtocolType)) It's not possible also. So, it's possible to use in my case a switch statement or not?

    Read the article

  • Using Enum in Hibernate causes select followed by an update statement

    - by Leonardo
    Hi all, I have a mapped entity wich has an enum property. By loking at log file, whenever I run a select statement on such entity, the result is an immediately following update. For example if my result set contains 100 records, then I have: [INFO org... select...] [INFO org... update... where id=?] [INFO org... update... where id=?] .... repeated 100 times If I mark the property as update=false the problem disappear. The enum is assigned trough an enum converter class, which I copied from a well known book. So I don't know if I just copy and paste the code. Here it is how is declared on hbm file. <typedef class="mypackage.HbnEnumConverter" name="the_type"> <param name="enumClassname">mypackage.TheType</param> </typedef> Can you point out a direction to investigate this ? Beside, what are the consequences of having update=false on hibernate field ? thanks

    Read the article

  • C++ packing a typedef enum

    - by Sagar
    typedef enum BeNeLux { BELGIUM, NETHERLANDS, LUXEMBURG } _PACKAGE_ BeNeLux; When I try to compile this with C++ Compiler, I am getting errors, but it seems to work fine with a C compiler. So here's the question. Is it possible to pack an enum in C++, or can someone see why I would get the error? The error is: "semicolon missing after declaration of BeNeLux". I know, after checking and rechecking, that there definitely is a semicolon there, and in any places required in the rest of the code.

    Read the article

  • Can I add and remove elements of enumeration at runtime in Java

    - by Brabster
    It is possible to add and remove elements from an enum in Java at runtime? For example, could I read in the labels and constructor arguments of an enum from a file? @saua, it's just a question of whether it can be done out of interest really. I was hoping there'd be some neat way of altering the running bytecode, maybe using BCEL or something. I've also followed up with this question because I realised I wasn't totally sure when an enum should be used. I'm pretty convinced that the right answer would be to use a collection that ensured uniqueness instead of an enum if I want to be able to alter the contents safely at runtime.

    Read the article

  • Use TinyInt to hide/show controls?

    - by grady
    Hi, I have 6 buttons on my GUI. The visibility of the buttons can be configured via checkboxes. Checking the checkbox and saving means the correpsonding button should be shown. I am wondering if it is somehow possible to have one TinyInt column in the database which represents the visibility of all 6 buttons. I created an enum for the buttons, it looks like that: public enum MyButtons { Button1 = 1, Button2 = 2, Button3 = 3, Button4 = 4, Button5 = 5, Button6 = 6 } Now I am wondering how to say that for example only button1, button5 and button6 are checked using this one column. Possible at all? Thanks :-)

    Read the article

  • How do I use an enum with custom values for a Sharepoint Web part?

    - by Jeff
    I'm trying to design a Web Part that has a drop-down list for the user to choose from. Eventually, these values will be automatically generated based on some kind of outside data source, so they're going to have somewhat arbitrary numeric values associated with them. This is the code I have now: public enum filterChoice { All=0, BOCC=12, Sustainability=15, Clerk=4, DA=13, Emergency=7, Highlights=3, POS=6, PR=1, PH=5, SHPR=2, Test=8, Transportation=14, Volunteer=16 }; These are different categories I want the user to choose from. When I choose one and save the settings for my Web Part, Sharepoint is only saving the values in numeric order; that is, All=0, BOCC=1, Sustainability=3 [...] so my Web Part then thinks the user chose the value with the corresponding number (PR when they chose BOCC, Highlights when they chose Sustainability, etc.) How can I make Sharepoint honor my custom values?

    Read the article

  • Declare java enum with a String array

    - by chama
    I'm trying to declare an enum type based on data that I'm retrieving from a database. I have a method that returns a string array of all the rows in the table that I want to make into an enumerated type. Is there any way to construct an enum with an array? This is what I tried, but from the way it looked in eclipse, it seemed like this just created a method by that name: public enum ConditionCodes{ Condition.getDescriptions(); } Thank you in advance!

    Read the article

  • Binding Enum[] to ListBox

    - by Polaris
    Hello. I have next enumeration Enum rcCategory { Incoming, Internal, Outgoing } and I have property "categories" in my class which has rcCategory[] type. I would like to bind this property to the listBox. I use next code for this MyListBox.SetBinding (ListBox.ItemsSource, new Binding {Source= myClass.categories}); But this code doesnt work as expected. How Can I do this. My listBox always is empty but source property has value

    Read the article

  • Setting enum values to 4-byte strings - why?

    - by psychotik
    I saw code similar to this in the Mac OS SDK: enum { kAudioFileStreamProperty_ReadyToProducePackets = 'redy', kAudioFileStreamProperty_FileFormat = 'ffmt', kAudioFileStreamProperty_DataFormat = 'dfmt', kAudioFileStreamProperty_FormatList = 'flst', kAudioFileStreamProperty_MagicCookieData = 'mgic', kAudioFileStreamProperty_AudioDataByteCount = 'bcnt', kAudioFileStreamProperty_AudioDataPacketCount = 'pcnt', kAudioFileStreamProperty_MaximumPacketSize = 'psze', kAudioFileStreamProperty_DataOffset = 'doff', kAudioFileStreamProperty_ChannelLayout = 'cmap', kAudioFileStreamProperty_PacketToFrame = 'pkfr', kAudioFileStreamProperty_FrameToPacket = 'frpk', kAudioFileStreamProperty_PacketToByte = 'pkby', kAudioFileStreamProperty_ByteToPacket = 'bypk', kAudioFileStreamProperty_PacketTableInfo = 'pnfo', kAudioFileStreamProperty_PacketSizeUpperBound = 'pkub', kAudioFileStreamProperty_AverageBytesPerPacket = 'abpp', kAudioFileStreamProperty_BitRate = 'brat' }; It's the first time I've seen this - I assume the compiler assigns the 32-bit integer equivalent of the strings to the enum values. I cannot think of a single good reason why this might be preferred over using simple integers. It looks hideous in a debugger (how do you tell which of these values corresponds to 1919247481?) and makes debugging just hard in general. So, is there any reason where assigning such strings to enum values actually makes sense.

    Read the article

  • Keep getting error class, interface, or enum expected

    - by user1746605
    I can't see the problem with this short class. I get 8 class, interface, or enum expected errors. Thanks public class BankAccount { public BankAccount { private double balance = 0; } public BankAccount(double balanceIn) { private double balance = balanceIn; } public double checkBalance { return balance; } public void deposit(double amount) { if(amount > 0) balance += amount; } public void withdraw(double amount) { if(amount <= balance) balance -= amount; } }

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >